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

677
Vistas
pass to body a base64 image in fetch

So the title says everything, I'm dealing with this problem for over a week, here is the thing, I want to send via fetch "body" a base64, here is my code

            const response = await fetch("/api/ipfs", {method: "POST", body: image });
            if (!response.ok) {
                throw new Error(`Error: ${response.status}`);
            }
            const result = await response.json()
            console.log(result.metadata)

the image variable is a base64 image. When I do that is outputs this error

TypeError: Cannot read properties of undefined (reading 'length')
at toUtf8Bytes (utf8.js?144e:176:21)
at StringCoder.encode (string.js?2fad:12:48)
at eval (array.js?4375:49:1)
at Array.forEach (<anonymous>)
at pack (array.js?4375:43:1)
at TupleCoder.encode (tuple.js?1c6b:51:20)
at AbiCoder.encode (abi-coder.js?2acc:87:1)
at Interface._encodeParams (interface.js?1df7:254:1)
at Interface.encodeFunctionData (interface.js?1df7:296:1)
at eval (index.js?b70c:125:1)
at Generator.next (<anonymous>)
at fulfilled (index.js?b70c:5:43)

I know that it means that the data I'm trying to pass needs to be in the correct format, but I already try passing the base64 as an array, String, also adding headers and using formdata but the error is the same. Any idea?

I'm using NEXTjs with the api to fetch it.

It works if I pass a normal string, but if I pass a base64 image it outputs that.

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