Skip to content Skip to sidebar Skip to footer

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(awaitexecute());

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

asyncfunctiontest() {
 const result = awaitexecute();
 console.log("result = ", result);
}

test();

Post a Comment for "Missing ) After Argument List Using Async Await"