Re: [whatwg/fetch] Explainer needed for creating requests (#1143)

+1, this would be good. Besides fields to set, some interesting points to cover:

- Should your request be sync (and in parallel) or async?
- How do you process results of the request? Does fetch return a response? Do you use the various tasks in https://fetch.spec.whatwg.org/#process-request-body ?
- Basic stuff after you get a response: check that it's not a network error; usually check that it's an ok status (don't check 200 specifically).
- How do you read the body of the request? Actually, this is not really clear: #661.
- What common things should you do with "modern" fetches? For example, use "cors" mode, check MIME types (using the specific verbiage "the result of extracting a MIME type from response's header list is...", with some advice about essence matches vs. exact matches), be careful with credentials mode, always use UTF-8 regardless of any headers telling you otherwise...
- How to deal with opaque responses? I think there's an "inner response" or "unsafe inner response" or something involved here.

Regarding fields specifically, a good heuristic is: if you would set them using the `fetch()` API, then set them when calling from other specs. Otherwise, you can leave them as the default. So this just reduces to the problem of understanding the `fetch()` API, which is relatively well-documented.

Except, specs really should be setting a destination, I think, which `fetch()` does not need configured...

-- 
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/1143#issuecomment-763859030

Received on Wednesday, 20 January 2021 18:53:40 UTC