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

121
Vistas
React and IPFS - Uncaught (in promise) TypeError: PubsubRouter is not a constructor

I am trying to fetch some json data on IPFS but keep getting hit by this error in the console on page load (and on click).

Uncaught (in promise) TypeError: PubsubRouter is not a constructor: pubsub-adapter.js:17

Heres my basic App.tsx:

import { ipfsFetch } from "ipfs-fetch"
import React, { useState } from "react"
import "./App.css"

function App() {
    const [tokenId, setTokenId] = useState()

    const fetchOnIpfs = async (tokenId: number) => {
        return await ipfsFetch(`<cid>/${tokenId}.json`)
    }

    return (
        <div className='App'>
            <input onChange={e => setTokenId(e.target.value)} />
            <button onClick={() => fetchOnIpfs(tokenId)}>TEST</button>
        </div>
    )
}

export default App

I am using the ipfs-fetch package uses the ipfs-core under the hood. I've tried using ipfs-core directly and other package ipfs packages which all give the same error.

On the other hand, this works fine:

const { ipfsFetch } = require("ipfs-fetch")

const main = async () => {
    const res = await ipfsFetch("<cid>/1.json")
    console.log(res.toString())
}

main()

Which leads me to believe that the problem has to do with react. What am I doing wrong? Is there a better way to do this in react?

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