create a file "index.js" and type the following code
let fs=require('fs');
let http=require('http');
let myWrite=fs.createWriteStream(__dirname+"/data/datatop.json","utf-8");
let server=http.createServer(function(req,res){
res.writeHead(200,{'content-type':'application/json'})
let myReadStream=fs.createReadStream(__dirname+"/data/data.json","utf-8");
myReadStream.pipe(res);
});
server.listen(3000);
console.log("server running @ 3000");
Create another file "employee.json" and type the following code
[{
"name":"abc",
"age":23,
"gender":"male"
},
{
"name":"def",
"age":24,
"gender":"female"
},
{
"name":"ghi",
"age":27,
"gender":"female"
}
]
under gitbash terminal compile the code using the following command
node index.js
view output in browser , under url section type: "localhost:3000/employee