I am new to node and running into this error on a simple tutorial.
I am on the OS X 10.8.2 trying this from CodeRunner and the Terminal.
I have also tried putting my module in the node_modules
folder.
I can tell this is some kind of connection problem but I have no idea why?
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:770:11)
at Object.afterConnect [as oncomplete] (net.js:761:19)
app.js:
var makeRequest = require('./make_request');
makeRequest("Here's looking at you, kid");
makeRequest("Hello, this is dog");
make_request.js:
var http = require('http');
var makeRequest = function(message) {
//var message = "Here's looking at you, kid.";
var options = {
host: 'localhost', port: 8080, path:'/', method: 'POST'
}
var request = http.request(options, function(response) {
response.on('data', function(data) {
console.log(data);
});
});
request.write(message);
request.end();
};
module.exports = makeRequest;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…