Missing ) After Argument List Using Async Await
I have a file call find.js, and I run with node find.js, my node is version 10 I have no clue why I fail to use async await. const axios = require('axios'); const execute = async
Solution 1:
Because an async
function returns an implicit Promise, you can change this:
console.log(await execute());
To this:
execute().then(res => console.log(res));
Otherwise, you would need to have your call to execute
inside of another async
function because await
can only be used inside of async
functions.
Solution 2:
put the execute
func inside async
function
async function test() {
const result = await execute();
console.log("result = ", result);
}
test();
Post a Comment for "Missing ) After Argument List Using Async Await"