react-fetch-utils 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{Readme.md → README.md} +15 -15
- package/package.json +1 -1
package/{Readme.md → README.md}
RENAMED
|
@@ -114,28 +114,28 @@ Behavior:
|
|
|
114
114
|
|
|
115
115
|
- Backward compatible with existing `respType: "json" | "raw"`.
|
|
116
116
|
- New parsing modes via `parseAs`:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
- `json` (default)
|
|
118
|
+
- `raw` (`Blob`)
|
|
119
|
+
- `text` (`string`)
|
|
120
|
+
- `response` (`Response`)
|
|
121
121
|
- Supports request timeout with `timeoutMs` using `AbortController`.
|
|
122
122
|
- Supports base URL joining with `baseUrl`.
|
|
123
123
|
- Supports request customization with `headers`, `onRequest`, `validateStatus`, and `getAuthToken`.
|
|
124
124
|
- `Accept` is set automatically only when caller did not provide it.
|
|
125
125
|
- `Content-Type: application/json` is added only when:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
- there is a body,
|
|
127
|
+
- method is `POST`/`PUT`/`PATCH`,
|
|
128
|
+
- `includeContentType !== false`,
|
|
129
|
+
- caller did not already provide `Content-Type`.
|
|
130
130
|
- Request body behavior:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
- `GET`/`HEAD` bodies are not sent by default.
|
|
132
|
+
- use `allowBodyForGetHead: true` to allow body on `GET`/`HEAD`.
|
|
133
|
+
- non-JSON bodies (`FormData`, `Blob`, `string`, `URLSearchParams`, etc.) are passed through unchanged.
|
|
134
|
+
- plain objects/values are JSON-stringified when body is allowed.
|
|
135
135
|
- Error model:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
- `401` rejects with `{ reason: "Unauthorized", details: Response }`
|
|
137
|
+
- timeout abort rejects with `{ reason: "Timeout", details: ... }`
|
|
138
|
+
- other failures reject with `{ reason: "Unknown", details: ... }`
|
|
139
139
|
- Returned promise remains cancellable with `.cancel()` and is safe to call repeatedly.
|
|
140
140
|
|
|
141
141
|
Example (JSON):
|