access json file in nodejs code example
Example 1: read json file nodejs
const fs = require('fs');
const path = require('path');
let rawdata = fs.readFileSync(path.resolve(__dirname, 'student.json'));
let student = JSON.parse(rawdata);
console.log(student);
Example 2: nodejs include json file
config = require("./yourfile.json"); // Note, "config" can be changed to your liking.