Created
June 22, 2021 08:50
-
-
Save artisandhq/3caf14fc34a2757b028b2a5637334d29 to your computer and use it in GitHub Desktop.
Async/Await with Nodejs File System. Reference: https://dev.to/starpebble/async-await-with-nodejs-file-system-1aa2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function f() { | |
const fsPromises = require('fs').promises; | |
const data = await fsPromises.readFile('/tmp/data.json') | |
.catch((err) => console.error('Error: ', err)); | |
return JSON.parse(data.toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment