import { createWriteStream } from "fs"; import { gunzip } from "zlib"; import CardMarketApi from "./api"; async function run() { let api = new CardMarketApi(); let data = await api.get("/productlist"); const gzipbuf = Buffer.from(data.productsfile, "base64"); gunzip(gzipbuf, (err, data) => { if (err) { throw err; } const file = createWriteStream("products.csv"); file.write(data, err => { if (err) { throw err; file.close(); } }); }); } run(); /* api.req("/users/104821/articles", "start=0&maxResults=100").then(response => { console.log(response); }) */