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

236
Views
JS-IPFS API doesn't work well when I use Ipfs.cat

I try to use js-ipfs. First I import ipfs using CDN.

<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.js"></script>

When I try ↓ this code, it worked well.

async function main (){
  const ipfs = await Ipfs.create()
  const cid = await ipfs.object.new({
    template: 'unixfs-dir'
  })
  window.alert(cid);
};
main();

However, When I try ↓ code, it doesn't work well.(reference: https://js.ipfs.io/)

async function main (){
  const ipfs = await Ipfs.create();
  const stream = ipfs.cat('QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A')
  let data = '';
  for await (const chunk of stream) {
    data += chunk.toString();
  };
  console.log(data);
};
main();

Please tell me what is the problem. I am stack in this point for 2 days.

about 4 years ago · Juan Pablo Isaza
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!