mirror of
https://github.com/labs42io/clean-code-typescript.git
synced 2025-04-18 15:13:34 +00:00
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
This commit is contained in:
parent
40ba290cc7
commit
0754bb53f5
1 changed files with 3 additions and 3 deletions
|
@ -2362,15 +2362,15 @@ import { promisify } from 'util';
|
|||
|
||||
const write = promisify(writeFile);
|
||||
|
||||
async function downloadPage(url: string, saveTo: string): Promise<string> {
|
||||
async function downloadPage(url: string): Promise<string> {
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue