不知道我在这里做错了什么?
错误:
/Users/user/node/app.js:3
makeRequest("Here's looking at you, kid");
^
TypeError: object is not a function
at Object.<anonymous> (/Users/user/node/app.js:3:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
应用程序.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();
};
exports = makeRequest;