sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API
MIT License
13.62k stars 363 forks source link

"fetch() request with GET/HEAD/OPTIONS method cannot have body" in Bun #527

Closed dimonnwc3 closed 1 year ago

dimonnwc3 commented 1 year ago

Following code throws an error:

const res = await ky.post(baseURL("/api/v1/countries"), {
      json: { email: "aaaaaaa", name: "a" },
})
TypeError: fetch() request with GET/HEAD/OPTIONS method cannot have body.
code: "ERR_INVALID_ARG_VALUE"
❯ bun --version
1.0.2
"ky": "^1.0.1",
sindresorhus commented 1 year ago

I recommend opening an issue on Bun. We have a test to prove it works fine in Node.js: https://github.com/sindresorhus/ky/blob/98d76e6d0827504b0f5574693eaa3feec664f06c/test/fetch.ts#L62-L66

dimonnwc3 commented 1 year ago

resolved with this: https://github.com/oven-sh/bun/issues/6144