Node.js
1const functions = require("firebase-functions"); 2const admin = require('firebase-admin'); 3let http = require('https'); 4admin.initializeApp(); 5 6 7exports.postalCode = functions.https.onCall(async (data, context) => { 8 //const URL = "https://zipcloud.ibsnet.co.jp/api/search?zipcode="+data.text; 9 const URL = 'https://zipcloud.ibsnet.co.jp/api/search?zipcode=100-0002'; 10 var data = []; 11 http.get(URL, (res) => { 12 let body = ''; 13 res.setEncoding('utf8'); 14 15 res.on('data', (chunk) => { 16 body += chunk; 17 data.push(body); 18 }); 19 20 res.on('end', (res) => { 21 return data[0]; 22 }); 23 }).on('error', (e) => { 24 console.log(e.message); //エラー時 25 }); 26});
このようなコード内容でアプリ側(Flutter)から叩いた時にdata[0]が返ってこないです
エラー文(Flutter側)
Error: [firebase_functions/internal] internal
at Object.throw_ [as throw] (http://localhost:8080/dart_sdk.js:5061:11) at https_callable_web.HttpsCallableWeb.new.call (http://localhost:8080/packages/cloud_functions_web/https_callable_web.dart.lib.js:39:23) at call.throw (<anonymous>) at http://localhost:8080/dart_sdk.js:38645:38 at _RootZone.runBinary (http://localhost:8080/dart_sdk.js:38515:59) at _FutureListener.thenAwait.handleError (http://localhost:8080/dart_sdk.js:33724:33) at handleError (http://localhost:8080/dart_sdk.js:34281:51) at Function._propagateToListeners (http://localhost:8080/dart_sdk.js:34307:17) at _Future.new.[_completeError] (http://localhost:8080/dart_sdk.js:34157:23) at async._AsyncCallbackEntry.new.callback (http://localhost:8080/dart_sdk.js:34193:31) at Object._microtaskLoop (http://localhost:8080/dart_sdk.js:38778:13) at _startMicrotaskLoop (http://localhost:8080/dart_sdk.js:38784:13) at http://localhost:8080/dart_sdk.js:34519:9
どうかご教授の程よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。