diff --git a/doc/api/fs.md b/doc/api/fs.md index 8c84e0d229fa13..4c1680191ae563 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -4941,6 +4941,18 @@ will be passed as `Buffer` objects. If `options.withFileTypes` is set to `true`, the resolved array will contain [`fs.Dirent`][] objects. +```js +const fs = require('fs'); + +async function print(path) { + const files = await fs.promises.readdir(path); + for (const file of files) { + console.log(file); + } +} +print('./').catch(console.error); +``` + ### `fsPromises.readFile(path[, options])`