๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

Uploading image to Sanity from Next.js API with server-side node.js

10 replies
Last updated: Apr 8, 2020
Trying to upload an image to Sanity from Next.js /api. What am I doing wrong? ๐Ÿ˜“
TypeScript doesn't complain about the type, but the error message says it's wrong type.
Apr 8, 2020, 10:05 AM
is this client side or server side?
Apr 8, 2020, 10:31 AM
Server side
Apr 8, 2020, 10:31 AM
This is next.js, and I'm pretty sure the
will result in a server side node.js thing.
Apr 8, 2020, 10:32 AM
what fetch polyfill/library are you using?
Apr 8, 2020, 10:33 AM
Apr 8, 2020, 10:33 AM
I don't think our node client can handle Blobs, any way to convert it to a buffer?
Apr 8, 2020, 10:34 AM
instead of
Apr 8, 2020, 10:37 AM
Ahh, that works! Typescript didn't know about
which didn't work.
Apr 8, 2020, 10:38 AM
to the rescue ๐Ÿ˜‰
Apr 8, 2020, 10:39 AM
Hehe ๐Ÿ˜… I just switched to
since this always will be server side, and now everything types correctly as well ๐Ÿฅณ
Apr 8, 2020, 10:41 AM

Sanityโ€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?