我试图从JSON调用单个数据,但是每当我返回变量时。它始终打印为“未定义”
helper.getCurrentWeatherByCityName("San Antonio, US", (err,
currentWeather) => {
if(err){
console.log(err);
}
else{
JSON.stringify(currentWeather.main.temp);
exWeather = console.log(currentWeather.main.temp);
console.log(currentWeather.main.temp);
// This will work and print out the city temp
}
});
console.log(“这是” + exWeather);
exWeather始终打印为未定义。