Closed thexpand closed 9 months ago
I'm not sure if this is related, but I'm also using Next 13.5.2 and a simple post request:
const data = await ky
.post(endpoint, {
json: {
some: 'json',
},
})
.json<SomeResponseType>();
results in:
Request with GET/HEAD method cannot have body.
Manually specifying { method: "POST" }
doesn't work either, so perhaps it's just not passing options at all?
This may because Ky is not passing options directly to fetch(…, options)
, but instead constructs a Request
and passes the options in there. My guess would be that Next.js does not correctly handle that.
Actually, yeah, this is the reason: https://github.com/sindresorhus/ky/issues/516#issuecomment-1674303251
I just came across the same issue when i tried to set the request priority. is this something ky should natively support (i can open issue for that, if needed) or left for after the option passthrough has been fixed?
When I try to pass down custom options to the native fetch, e.g. Next.js 13's
{ next: { revalidate: 0 } }
, these options don't get passed to thefetch
function. Here's the issue created in Next.js's repo, but the problem is that actually ky doesn't pass the custom options: https://github.com/vercel/next.js/issues/48519References about how to use the options in the Next.js docs: