Javascript 错误:connect ETIMEDOUT,Node js如何在localhost API和#x27;s
我有一些后端服务正在监听端口8080。我在NodeJS中还有另一个API,它正在本地主机上的端口3000上监听 如何从节点服务器与后端API通信 这是我的节点js代码:Javascript 错误:connect ETIMEDOUT,Node js如何在localhost API和#x27;s,javascript,node.js,http,proxy,reverse-proxy,Javascript,Node.js,Http,Proxy,Reverse Proxy,我有一些后端服务正在监听端口8080。我在NodeJS中还有另一个API,它正在本地主机上的端口3000上监听 如何从节点服务器与后端API通信 这是我的节点js代码: router.post('/', function(req, res, next) { console.log('got validate request'); var options = { host:'localhost', port:8080, path:'/***/getservice
router.post('/', function(req, res, next) {
console.log('got validate request');
var options = {
host:'localhost',
port:8080,
path:'/***/getservice',
method:'GET'
}
http.request(options, function (response) {
console.log('response:', response); // Print the error if one occurred
res.json(response);
res.end();
});
});
上述代码导致错误:connect ETIMEDOUT