Node.js 使两个本地nodejs服务器相互请求和res

Node.js 使两个本地nodejs服务器相互请求和res,node.js,server,Node.js,Server,学习有关nodejs服务器之间的req和res的一些基础知识 希望服务器1向服务器2发送get 服务器1: var http = require('http'); http.get("http://localhost:8080/", function(res) { console.log("what's going on?") }); 服务器2: var http = require('http'); http.createServer(function (req, res) {

学习有关nodejs服务器之间的req和res的一些基础知识

希望服务器1向服务器2发送
get

服务器1:

var http = require('http');
http.get("http://localhost:8080/", function(res) {
    console.log("what's going on?")
});
服务器2:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write(req.url);
    res.end('Hello World!');
}).listen(8080);
对于一些有经验的人来说,这显然是行不通的

Error: connect ECONNREFUSED 127.0.0.1:8080
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
请问出了什么问题以及如何使其工作? 只要一些提示就好了。
如果您建议使用“请求”模块,请同时提供没有该模块的解决方案。

我找到了原因。。事实上,代码没有任何问题。 这是nodemon的时机, 两个.js文件放在同一个文件夹中,更改一个会导致两个nodemon重新启动,
对8080的请求,服务器正在重新启动,无法响应。

第一个实际上不是服务器,它只是由另一个由节点服务器运行的文件的请求。JSI没有添加拇指,我会考虑您的建议。