-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