NuxtN
Nuxt3y ago
9 replies
dmarr

Making POST or PATCH requests with $fetch?

I would like to send a request to an external API using $fetch. I am getting some errors when doing something like so:
body = await readBody(event);
headers = { authorization: 'foo' }
$fetch('https://foo.com/api', { body, headers, method: 'POST' })

The response from the server is "invalid JSON". I am inspecting the request before it goes out and it looks like a valid object.
Was this page helpful?