Get the whole response body when the response is chunked?

前端 未结 7 989
旧巷少年郎
旧巷少年郎 2020-12-08 06:32

I\'m making a HTTP request and listen for \"data\":

response.on(\"data\", function (data) { ... })

The problem is that the response is chun

7条回答
  •  眼角桃花
    2020-12-08 06:58

    The reason it's messed up is because you need to call JSON.parse(data.toString()). Data is a buffer so you can't just parse it directly.

提交回复
热议问题