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.