#$fetch with server API endpoint and multipart form data

6 messages · Page 1 of 1 (latest)

lost portal
#

I can't work out how to send a file from my page to a Nuxt 3 server API endpoint.

  • Bottom-left: page code. Highlighted is the snippet which creates formData and sends it to my api endpoint using $fetch.
  • Bottom-right: the endpoint itself
  • Top: browser console logging from line 147 of page code. Shows the formData has a file and an id.
  • Bottom far-right: no logs in console. Nothing. I can't get it to read data from the request.

If I log a fixed string at the dop of the defineEventHandler function, it will log to the terminal. But if I try and log after trying to run readMultipartFormData, it will not log. I have tried to catch errors from readMultipartFormData and nothing.

last vault
#

Hey Kevin, I got the same problem. Do you want to use the image at your nuxt3 server or only want to upload it to a storage provider?

lost portal
#

The latter

#

And that would be an SDK method call

last vault
lost portal
#

Thanks I’ll take a look!