Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get json data from json file in node js

const fs = require("fs"); 
var posts = [];

fs.readFile('./data/posts.json', 'utf8', (err, data) => {
                if (err) throw err;
                posts = JSON.parse(data);
            });
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #json #data #json #file #node #js
ADD COMMENT
Topic
Name
2+4 =