Created
December 9, 2022 06:48
-
-
Save kwokhou/1381ef0182d9e7eb0cee4d6224ba9e72 to your computer and use it in GitHub Desktop.
NodeJS Read JSON file
This file contains 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
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