Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 390 Bytes

2024-03-02:Web JavaScript, How to fetch and read gzip JSON file with native API.md

File metadata and controls

12 lines (9 loc) · 390 Bytes

2024-03-02:Web JavaScript, How to fetch and read gzip JSON file with native API.md


const response = await fetch('.../users_10k.json.gz')
const ds = new DecompressionStream('gzip');
const decompressed_stream = response.body.pipeThrough(ds);
const decompressed_text = await new Response(decompressed_stream).text();
console.log(decompressed_text) // { ... }