问题
I am using Axios to get the JSON response from the web server. The response is in compressed gzip format. How can I decompress the response and get the Json Data.
回答1:
const zlib = require('zlib')
let url = "https://example.com/GZ_FILE.gz"
const { data } = await axios.get(url, { responseType: 'arraybuffer' })
zlib.gunzip(data, function (_err, output) {
console.log(output.toString())
})
来源:https://stackoverflow.com/questions/62882796/how-to-decompress-gzip-json-response-via-axios