- From: Zamralik <notifications@github.com>
- Date: Fri, 16 Apr 2021 10:35:18 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 16 April 2021 17:35:31 UTC
Rather than fix the implementation, they opted to subset the HTTP specification to fit the implementation of fetch(). Rule 33 of "The new Request(...) constructor steps are:" https://fetch.spec.whatwg.org/#dom-request > If either init["body"] exists and is non-null or inputBody is non-null, and request’s method is `GET` or `HEAD`, then throw a TypeError. Which prevents doing clean call with complex nested structures like the fake code below. ``` const response = await fetch("/endpoint/search-something", { method: "GET", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ foo: { bar: "qux", qux: { bar: "foo" } } }) }); ``` If you wanted to make a proper API to handle front & back interactions, you can't. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/551#issuecomment-821330110
Received on Friday, 16 April 2021 17:35:31 UTC