튜토리얼
Node.js에 내장된 http 모듈의 createServer 함수를 사용한 Webhook 수신 예제코드입니다.
Webhook 이벤트 메시지의 추가적인 항목은 하단의 [Webhook 메시지 구성]을 참조하시기 바랍니다.
var http = require('http');
http.createServer(function(req, res) {
var jsonData = "";
req.on('data', function(chunk) {
jsonData += chunk;
});
req.on('end', function(){
// JSON Parse, 추가적인 항목은 하단의 [Webhook 메시지 구성]을 참조하여 필드 추가
var reqObj = JSON.parse(jsonData);
console.log(reqObj);
console.log(reqObj['eventDT']);
console.log(reqObj['eventType']);
// Response 성공 처리.
res.writeHead(200);
res.end('{"result":"OK"}');
});
}).listen(80);












