DEV Community

Discussion on: Parsing JSON with Node.js

Collapse
 
janpot profile image
Jan Potoms

The upcoming async interface for fs cleans this up a little further:

const fs = require('fs').promises

(async () => {
  try {
    const data = JSON.parse(await fs.readFile('/path/to/file.json', 'utf8'))
  } catch(err) {
    console.error(err)
  }
})()