Json connecivity using node.js

create af file in "index.js" and type the following code and create another file "animal.json" and list the attributes of animal ,view the output in browser . type "localhost:3000/" in URL section.

let fs=require('fs');
let myReadStream=fs.createReadStream(__dirname+"/data/data.json","utf-8");
let myWrite=fs.createWriteStream(__dirname+"/data/datatop.json","utf-8");
myReadStream.pipe(myWrite);//creates a file
myReadStream.on('data',function(response){
console.log(response);//used to get output in gitbash
});
Posted on by