【发布时间】:2020-12-17 23:56:17
【问题描述】:
我有以下代码...
run(cert).then( serverPop => {
const popInt = parseInt(serverPop);
console.log("The new pop resport is: " + serverPop);
if (oldPop < popInt) {
let addDB = "https://www.website.com/u.php?o=" + oldPop + "&c=" + cert + "&n=" + popInt;
const popIntoDoResponse = await axios.get(addDB); //error here
res.json({
ack: "success",
message: "POP IS UPDATED",
pop: popInt,
serverResponse: popIntoDoResponse.data
});
} else {
res.json({
ack: "success",
message: "POP IS THE SAME",
pop: popInt
});
}
我在日志中得到以下指向await
await 只在 async 函数中有效
【问题讨论】:
标签: node.js promise async-await