Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

javascript - Changed from btao to Buffer but recieving TypeError when pushing to Vercel

So i have this application in Next js where i need to encode my image to base64. I first tried using btao and it worked fine until i tried pushing to vercel which gave an error that btao was undefined. I looked up how to fix it and found that using

Buffer.from(
   icon,
   "binary"
).toString("base64")

should work but after pushing to vercel again it gave me the following error:

Unhandled error during request: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received null

Has anyone else encountered this?

question from:https://stackoverflow.com/questions/65873087/changed-from-btao-to-buffer-but-recieving-typeerror-when-pushing-to-vercel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have found the awnser.

So my svf was saved as a raw string in my state and when the page loaded it was being encoded using Buffer.

To solve my issue i encoded the svg string with Buffer at the moment of upload and kept the encoded string as state so i didn't have to encode it when a page loads in.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...