我正在从Parse Cloud Code运行Parse.Cloud.httpRequest到Google Geocoding API。 请求工作正常。但是,我无法检索数据。
请求:
var url_gg = 'https://maps.googleapis.com/maps/api/geocode/json?address='+encodeURI(place)&key=key;
Parse.Cloud.httpRequest({method: 'GET', url: url_gg}).then(function(response){
console.log(response.text);
console.log(response.data);
});
这是来自response.text
的日志"results" : [
{
"address_components" : [
{
... (truncated)
这是来自response.data
的日志{"results":[],"status":"OK"}
当我尝试使用JSON.parse(response.text)时,我得到了相同的结果:"结果"数组为空,而它在response.text
中不为空如何获取结果数组的值?
非常感谢! 马克西姆。
编辑:这是响应
{"uuid":"b6efde3a-759b-1fa3-46e5...","status":200,"headers":{"Access-Control-Allow-Origin":"*","Alt-Svc":"quic=\":443\"; p=\"1\"; ma=604800","Alternate-Protocol":"443:quic,p=1","Cache-Control":"public, max-age=86400","Content-Encoding":"gzip","Content-Type":"application/json; charset=UTF-8","Date":"Fri, 04 Sep 2015 18:10:55 GMT","Expires":"Sat, 05 Sep 2015 18:10:55 GMT","Server":"mafe","Transfer-Encoding":"chunked","Vary":"Accept-Language","X-Frame-Options":"SAMEORIGIN","X-XSS-Protection":"1; mode=block"},"text":"{\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"1\",\n \"short_name\" : \"1\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Chemin de ...\",\n \"short_name\" : \"Chemin de ...\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_na... (truncated)
enter code here