From 0754bb53f5d9dd5b6de67871b926eea8edd5c92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0ulovsk=C3=BD?= Date: Thu, 30 Jun 2022 21:12:42 +0200 Subject: [PATCH] Remove side effects from function in async/await example While this is not the point of the example, it would be good to keep the code consistent across examples --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5a20351..ac0c9a4 100644 --- a/README.md +++ b/README.md @@ -2362,15 +2362,15 @@ import { promisify } from 'util'; const write = promisify(writeFile); -async function downloadPage(url: string, saveTo: string): Promise { +async function downloadPage(url: string): Promise { const response = await get(url); - await write(saveTo, response); return response; } // somewhere in an async function try { - const content = await downloadPage('https://en.wikipedia.org/wiki/Robert_Cecil_Martin', 'article.html'); + const content = await downloadPage('https://en.wikipedia.org/wiki/Robert_Cecil_Martin'); + await write('article.html', content); console.log(content); } catch (error) { console.error(error);