How do I ungzip (decompress) a NodeJS request's module gzip response body?

前端 未结 9 1219
日久生厌
日久生厌 2020-11-27 04:21

How do I unzip a gzipped body in a request\'s module response?

I have tried several examples around the web but none of them appear to work.

request(         


        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 04:46

    With got, a request alternative, you can simply do:

    got(url).then(response => {
        console.log(response.body);
    });
    

    Decompression is handled automagically when needed.

提交回复
热议问题