Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda