我需要将响应数据设置为context.forecast。我尝试在if循环中使用GET方法,但上下文变得未定义。有没有办法在外部定义GET函数,只是调用将值转换为数据变量?
注意:位置变量需要传递到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;
}