关于调用百度地图api问题
发布于 7 年前 作者 qijianzhong 4599 次浏览 来自 问答

这段代码有错吗?为什么调用不了百度地图api

var request = require(‘request’); request(‘http://api.map.baidu.com/geocoder/v2/?callback=renderReverse&location=39.983424,116.322987&output=json&pois=1&ak=xxxxxx’, function (error, response, body) { console.log(‘error:’, error); // Print the error if one occurred console.log(‘statusCode:’, response && response.statusCode); // Print the response status code if a response was received console.log(‘body:’, body); // Print the HTML for the Google homepage. });

CMD 运行后结果:

D:\Nodejs\company>node app2.js error: { Error: connect ECONNREFUSED 103.235.47.88:80 at Object._errnoException (util.js:1041:11) at _exceptionWithHostPort (util.js:1064:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1153:14) code: ‘ECONNREFUSED’, errno: ‘ECONNREFUSED’, syscall: ‘connect’, address: ‘103.235.47.88’, port: 80 } statusCode: undefined body: undefined

D:\Nodejs\company>

5 回复

被拒绝了,看看什么原因,是不是对请求调用者有特征要求,比如 UA 等

@DevinXian 科普一下,什么叫特征要求? 我这里还要设置什么的吗?

@DevinXian 问题解决了,是代理的问题,是公司设置了代理,用非公司网络就能访问

@qijianzhong 哈哈哈,我想多了

回到顶部