node.js에서 작동하도록 간단한 http 요청을받을 수없는 것 같습니다. 다음 코드는 아무것도 기록하지 않거나 오류를 인쇄하지 않고 멈 춥니 다.node.js http 모듈 사용
http = require 'http'
callback = (response) ->
console.log 'callback'
str = ''
# another chunk of data has been recieved, so append it to `str`
response.on 'data', (chunk) ->
console.log 'data'
str += chunk
# the whole response has been recieved, so we just print it out here
response.on 'end', ->
console.log str
http.get 'http://hacker-news.firebaseio.com/v0/topstories.json', callback
생성 된 자바 스크립트 :
// Generated by CoffeeScript 1.10.0
(function() {
var callback, http;
http = require('http');
callback = function(response) {
var str;
console.log('callback');
str = '';
response.on('data', function(chunk) {
console.log('data');
return str += chunk;
});
return response.on('end', function() {
return console.log(str);
});
};
http.get('http://hacker-news.firebaseio.com/v0/topstories.json', callback);
}).call(this);