how to fetch json data from local in javascript code example
Example: how to fetch local json file in javascript
Try to use file system. Don't think reading from a JSON file works like that.
const fs = require('fs');
const json_data = require('../services/contributors.JSON');
fs.readFile(json_data, 'utf8', function (err, data) {
try {
data = JSON.parse(data)
for (let i in data){
console.log('Name:',data[i].name)
}
} catch (e) {
// Catch error in case file doesn't exist or isn't valid JSON
}
});