Skip to content

Commit de1a68f

Browse files
authored
Ch9 - fix broken async JS example (#258)
1 parent 7c98606 commit de1a68f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

text/chapter9.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ A convenient way to work with asynchronous code in JavaScript is with [`async` a
2525

2626
Here is an example of using this technique to copy the contents of one file to another file:
2727

28-
``` js
29-
var fs = require('fs');
28+
```js
29+
var fsPromises = require('fs').promises;
3030

3131
async function copyFile(file1, file2) {
32-
let data = await fs.readFile(file1, { encoding: 'utf-8' })
33-
fs.writeFile(file2, data, { encoding: 'utf-8' })
32+
let data = await fsPromises.readFile(file1, { encoding: 'utf-8' });
33+
fsPromises.writeFile(file2, data, { encoding: 'utf-8' });
3434
}
3535

3636
copyFile('file1.txt', 'file2.txt')

0 commit comments

Comments
 (0)