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

164
Vistas
Read a JSON text from IPFS with Javascript

I did not find yet anywhere a working solution for this simple thing: I want to read the content of an IPFS JSON file that I previously uploaded.

const chunks = [];
const client = await create('https://ipfs.infura.io:5001/api/v0');

for await (const chunk of client.cat(
  'QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A',
)) {
  chunks.push(chunk);
}

console.log(chunks);

Output: 72,101,108,108,111,44,32,60,89,79,85,82,32,78,65,77,69,32,72,69,82,69,62

I tried this snippet that I found in various formats on the internet. But it gives me a Uint8Array that consists of numbers. Yet I was not able to convert chunks to a JSON object as I need it. Can somebody please provide a snippet for this, please?

I am using

"ipfs-http-client": "^53.0.1"

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You'll need to convert the Uint8Array buffer to a string first:

const result = JSON.parse(chunk.toString());
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