Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Unpack a gzip file that is content-disposition: attachment

I got the url to an api, when I visit the url in browser and pass my login, it will correctly download a zip file, that contains the JSON file with the data I want.

How do I get this JSON by fetching it with Node?

When I call like this

const data = await fetch(url, {
    headers: {
      Authorization: "Basic " + btoa(username + ":" + password)
    }
});

I correctly receive a data.body and data.headers but nothing near by the JSON data I am looking for.

Is it even possible to make an API call to a file that is attached?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

My solution:

import request from "request";
import zlib from "zlib";
import concat from "concat-stream";

const btoa = (str) => Buffer.from(str).toString("base64");

request(url, {
  headers: {
    Authorization: "Basic " + btoa(username + ":" + password),
  }})
    .pipe(zlib.createGunzip())
    .pipe(
       concat((stringBuffer) => {
         console.log(stringBuffer.toString()) // gives me the json I was looking for
       })
     );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!