Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

683
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda