parsing内容Webhooks(自定义JSONtypes)

目前,我正在使用此Contentful-webhook服务器在内容未发布时侦听webhook。

server.listen(30000, function(){ console.log('Contentful webhook server running on port ' + 30000) }); server.on('ContentManagement.Entry.publish', function(req){ console.log('An entry was published!', req); }); server.on('ContentManagement.Entry.unpublish', function(req){ console.log('An entry was unpublished!'); console.log('Deleted SOLR ID: ', req); }); 

我试图parsing我得到的响应,但我似乎无法find一种方法来parsing它们在响应中使用的自定义JSON。 我应该创build自己的服务器与快递还是缺less一种方法来获得在这个示例代码中的响应正文。

contentful-webhook-servercontentful-webhook-server使用纯节点http模块。 因此, req对象是一个可读的stream,你需要缓冲和parsing才能得到正文。

https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/#request-body为例。

    Interesting Posts