Friday, 26 May 2017

How to get responce of JSON file which send request through node js?

Here i want to get responce which return me a location according latitude and longitude that ill written in JSON file as request and give this JSON file reference in node js file.

My JSON file is:

{
    "request":
     {
        "apiKey" : "AIzaSyAsluFEA_Gkhbx6amt6_RWYPCiqnpFWjPM",
        "location" :
         {
                    "lat":"23.00",
                     "lng":"72.00"
         }
    }
}


and my node js code is:

var fs = require('fs');
fs.readFile('./place.json', 'utf8', onFileRead);// JSON file reference.

function onFileRead(err, data) {
    if (err) throw err;
    var currentPackage = JSON.stringify(JSON.parse(data));
    console.log(currentPackage);
}


"Place.json" is my JSON file name. This file return output:

{"request":{"apiKey":"AIzaSyAsluFEA_Gkhbx6amt6_RWYPCiqnpFWjPM","location":{"lat":"23.00","lng":"72.00"}}}

Here i write a "readfile" so it return same JSON code in output,i can't find code that return a responce of google map location which i want.. Please help me, which code or function return a responce according my request?? 



via vaishali bagul

No comments:

Post a Comment