Skip to content

Instantly share code, notes, and snippets.

@kwokhou
Created December 9, 2022 06:48
Show Gist options
  • Save kwokhou/1381ef0182d9e7eb0cee4d6224ba9e72 to your computer and use it in GitHub Desktop.
Save kwokhou/1381ef0182d9e7eb0cee4d6224ba9e72 to your computer and use it in GitHub Desktop.
NodeJS Read JSON file
const fs = require('fs')
const path = require('path')
async function start () {
const filepath = path.resolve(__dirname, 'config.json')
const config = await fs.promises.readFile(filepath, 'utf8')
const json = JSON.parse(config)
console.log(json)
}
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment