我需要将响应数据设置为 context.forecast。我尝试在 if 循环中使用 GET 方法,但上下文变得未定义。有没有办法在外面定义 GET 函数,然后调用将值放入数据变量中?
注意:location 变量需要传入 GET URL
getForecast({context, entities}) {
var location = firstEntityValue(entities, 'location');
if (location) {
delete context.missingLocation;
//TODO
//var data = GET URL
context.forecast = data
})
} else {
context.missingLocation = true;
delete context.forecast;
}
return context;
}