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

163
Views
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 answers
Answer question

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 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!