doc: update fs promise-based examples

https://github.com/nodejs/node/pull/34843 was cherry-picked onto
`v12.x-staging` in 961844d25b but the `fs/promises` API, as used
in the examples, is only available from Node.js 14. Change the
added examples to use `require(fs).promises` instead.

PR-URL: https://github.com/nodejs/node/pull/35760
Fixes: https://github.com/nodejs/node/issues/35740
Refs: https://github.com/nodejs/node/pull/34843
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Richard Lau authored and Myles Borins committed 2020-11-16 11:57:52 -05:00
1 parent 0f757bc2df
commit 68c5ee45a2
1 file changed
+2 -2
+2 -2
View File
@@ -60,7 +60,7 @@ Promise-based operations return a `Promise` that is resolved when the
asynchronous operation is complete.
```js
const fs = require('fs/promises');
const fs = require('fs').promises;
(async function(path) {
try {
@@ -106,7 +106,7 @@ fs.rename('/tmp/hello', '/tmp/world', (err) => {
Or, use the promise-based API:
```js
const fs = require('fs/promises');
const fs = require('fs').promises;
(async function(from, to) {
try {