我有一个文件调用 find.js,我使用节点 find.js 运行,我的节点是版本 10 我不知道为什么我无法使用 async await。
const axios = require("axios");
const execute = async () => {
let searchResult;
try {
searchResult = await axios.post(
"https://example.io/car",
{
ids: [12,31],
},
{
headers: {
"Accept-Language": "en-US",
},
}
);
} catch (error) {
console.log("error", error);
}
return searchResult;
};
console.log(await execute()); // error on this line
Run Code Online (Sandbox Code Playgroud)