Get the whole response body when the response is chunked?

前端 未结 7 988
旧巷少年郎
旧巷少年郎 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:51

    If you don't mind using the request library

    var request = require('request');
    request('http://www.google.com', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log(body) // Print the google web page.
      }
    })
    

提交回复
热议问题