Yes, as @DanStarns told in his answer,
I tried to implement this example,
import axios from 'axios';
const response = await axios('https://quote-garden.herokuapp.com/api/v2/quotes/random');
console.log(response.data);
package.json
{
"name": "async-await-top",
"version": "1.0.0",
"description": "",
"main": "top-level-async-await.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2"
}
}
Run with flag
node --harmony-top-level-await top-level-async-await.js
Output
G:\async-await-top>node --harmony-top-level-await top-level-async-await.js
{
statusCode: 200,
quote: {
_id: '5eb17aaeb69dc744b4e72b82',
quoteText: 'I can take more punishment than anyone in the business.',
quoteAuthor: 'Ric Flair',
quoteGenre: 'business',
__v: 0
}
}