我是javascript的新手。我试图从地理编码api中检索json对象,并将纬度和经度读入两个变量。这是我到目前为止所做的。它给我一个错误的json,我正在努力处理json。
var http = require('http');
var https = require('https');
var options = { //setting options..host,port,path etc..
host: 'maps.googleapis.com',
path: 'maps/api/geocode/json?address=london+&key=KEY',
method: 'GET',
var request = http.get(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
console.log(info);
} else {
console.log(error);
}
});