-1
我有一個函數updateMessage,它執行的值檢查,通過函數checkWeather()
調用天氣API,並將該API的結果附加到finalResponse
變量。返回函數值
但是,當我在updateMessage
函數內調用checkWeather()
時,我總是收到undefined
。
checkWeather
函數工作正常,但由於某種原因,當我嘗試返回其值時,它的超出範圍。
function updateMessage(payload, response) {
//Set var to JSON value
let finalResponse = response.output.text;
// Set var to function and return it
weatherData = checkWeather(appCity, appST);
return finalResponse.push(weatherData);
}
function checkWeather(...)
完整的代碼可以在此要點here
也許'checkWearher'是異步因爲某些原因? – csanonymus
'Array.prototype.push'不返回對該方法被調用的數組的引用,它可能與此處相同 – Vivick