如何从节点Js(Express)中的request()函数中获取响应(数据)

时间:2019-03-08 10:18:14

标签: javascript node.js express

        var address =  [];
        var result = '';
        request(`https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyADhcyBu7Ce_cN8RUBTt4T1lBq2X6L-_-w&latlng=${lat},${lng}`, function(error, response, data) {
          data = JSON.parse(data);
          address.push(data.results[0].formatted_address); 
          result = data.results[0].formatted_address;
          console.log(results);
          });
          results[i].address = result;
          results[i].address = address;
        }

我想从设置结果的请求函数中获取数据[i] .address = address;

请帮助我...

0 个答案:

没有答案