-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Closed
Description
In section Async/Await are even cleaner than Promises there are too many await
s, the ones on require()
calls are not necessary.
I believe the code should be:
async function getCleanCodeArticle() {
try {
const response = await require('request-promise').get('https://en.wikipedia.org/wiki/Robert_Cecil_Martin');
await require('fs-promise').writeFile('article.html', response);
console.log('File written');
} catch(err) {
console.error(err);
}
}
Though I would execute the require()
calls in the code outside the function, in this and in all other examples.
Metadata
Metadata
Assignees
Labels
No labels