0
,直到我的函數結束,我不能達到我值之前,導致..我試過的回調,但它似乎沒有工作..獲取功能節點的結束
exports.helloHttp = function helloHttp (req, res) {
var url = "https://api.coindesk.com/v1/bpi/currentprice.json";
var btcValue
require('https').get(url, function(res, btcValue){
var body = '';
res.on('data', function(chunk){
body += chunk;
});
res.on('end', function(){
btcValue = JSON.parse(body);
callback(btcValue);
});
}).on('error', function(e){
console.log("Got an error: ", e);
});
console.log("Got a respons ", btcValue);
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({ "speech": response, "displayText": response
}));
};
感謝很多提前
'callback'在哪裏?你只是調用回調,但它在哪裏?上面的代碼應該拋出錯誤'未定義回調「 – Subburaj