You can only use await inside a async function.
Will not work:
function notAsync () {
await aPromise()
}
Will Work:
async function isAsync() {
await aPromise()
}
Example with arrow function
const isAsync = async () => {
await aPromise()
}
2
solved Why not able to use await in Node.js? [duplicate]