【发布时间】:2020-09-23 00:36:37
【问题描述】:
这是一个超级代理调用,我已经导入了请求(即从我的超级代理组件类中导出) 如何在“res.resImpVariable”中使用 async/await。
request
.post(my api call)
.send(params) // an object of parameters that is to be sent to api
.end((err, res) => {
if(!err) {
let impVariable = res.resImpVariable;
} else {
console.log('error present');
}
});
【问题讨论】:
-
这适用于回调模式,因此将其移动到异步等待将需要您将更改转换为返回承诺
-
确定,如何在代码中添加?
标签: javascript reactjs asynchronous mobx superagent