0

I want to get an image from IPFS into my Vue/Nuxt project. I already import ipfs by 'npm i ipfs'. But when i run "cont node = Ipfs.create()". it show error enter image description here but this error doesn't always happen, many times it works and I can get the image normally. Has anyone ever encountered this situation and have a solution?

async downloadImg () {
  const node = await Ipfs.create()
  const { agentVersion, id } = await node.id()
  this.agentVersion = agentVersion
  this.id = id
  const cid = '/ipfs/QmY2dod6X7GFmqnQ6qCBiaeNxJWa3CYQaxEjGUfL5CqMAj'
  // load the raw data from js-ipfs (>=0.40.0)
  const bufs = []
  const a = node.cat(cid)
  for await (const buf of node.cat(cid)) {
    bufs.push(buf)
  }
  const data = Buffer.concat(bufs)
  const blob = new Blob([data], { type: 'image/jpg' })
  this.imageSrc = window.URL.createObjectURL(blob)
},

2 Answers2

0

If am I true it can depends on the web protocol which you use, if you use https its work and in other protocol not !

soroush
  • 742
  • 6
  • 10
0

The web crypto API is only available on pages accessed via https. If you're seeing that message, you are probably accessing the page via plain http.

Follow the github link at the top of the stack trace for more explanation and solutions.

achingbrain
  • 191
  • 2