You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 3, 2023. It is now read-only.
| url || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The URL to send the request to |
177
+
| method |`'GET'`| From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The HTTP method to use |
178
+
| body || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The request body to send along with the request |
179
+
| credentials || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The request credentials you want to use for the request: `omit`, `same-origin`, or `include.`|
180
+
| headers || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). Headers to send along with the request |
181
+
|[children](#children)|| A function that is called with a single argument containing information about the request. Learn more. |
182
+
|[lazy](#lazy)|_Varies_| Whether or not the request is made when the component mounts. |
183
+
|[beforeFetch](#beforefetch)|| A function called before a network request is made. |
184
+
|[afterFetch](#afterfetch)|| A function that is only called after a network request is made. |
185
+
|[onResponse](#onresponse)|| A function called anytime a response is received, whether from the network or cache. |
186
+
|[transformData](#transformdata)|| A function that is called with the body of the response, allowing you to transform it. |
187
+
|[responseType](#responsetype)|`'json'`| Whether or not the request is made when the component mounts. |
188
+
|[requestName](#requestname)|| A name to give this request, which can be useful for debugging. |
189
+
|[fetchPolicy](#fetchpolicy)|| The cache strategy to use. |
190
+
|[cacheResponse](#cacheresponse)|_Varies_| Whether or not to cache the response for this request. |
191
+
|[dedupe](#dedupe)|`true`| Whether or not to dedupe this request. |
192
+
|[requestKey](#requestkey)|_Generated_| A key that is used for deduplication and response caching. |
193
+
| mode || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The mode you want to use for the request |
194
+
| cache || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The browser's cache mode you want to use for the request |
195
+
| redirect || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The redirect mode to use |
196
+
| referrer |`'about:client'`| From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). The referrer to use for the request |
197
+
| referrerPolicy |`''`| From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). Specifies the value of the referer HTTP header. |
198
+
| integrity |`''`| From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). Contains the [subresource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) value of the request |
199
+
| keepalive || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). Can be used to allow the request to outlive the page |
200
+
| signal || From [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch). An AbortSignal object instance |
201
+
202
+
To learn more about the valid options for the props that come from `fetch`, refer to the
| fetching | Boolean | A Boolean representing whether or not a request is currently in flight for this component |
233
+
| failed | Boolean | A Boolean representing whether or not the request failed for any reason. This includes network errors and status codes that are greater than or equal to`400`. |
234
+
| error | Object | An error object representing a network error occurred. Note that HTTP "error" status codes do not cause errors; only failed or aborted network requests do. For more, see the ["Using Fetch" MDN guide](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful). |
235
+
| response | Object | An instance of [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). The [`body`](https://developer.mozilla.org/en-US/docs/Web/API/Body) will already be read, and made available to you as `response.data`. |
236
+
| data | Object | The data returned in `response`. This will be different from `response.data` if a `transformData` prop was passed to `<Fetch/>`. |
237
+
| doFetch | Function | A function that allows you to manually make the HTTP request. [Read more.](#using-dofetch)|
238
+
| url | String | The URL that was passed as a prop to `<Fetch />`|
239
+
| requestName | String | The name of the request (see `requestName` below) |
240
+
| requestKey | String | The [request key](./docs/guides/request-keys.md) of the request |
241
+
242
+
###### Using doFetch
219
243
220
244
There are three common use cases for the `doFetch` prop:
221
245
@@ -232,6 +256,20 @@ component's state.
232
256
`doFetch` returns a Promise that **always** resolves. It resolves to the same argument that the
233
257
[`afterFetch`](#afterFetch) prop receives.
234
258
259
+
In the following example, we demonstrate how you can modify the request by passing options to `doFetch`.
260
+
261
+
```jsx
262
+
<Fetch {...props}>
263
+
{({ doFetch }) => (
264
+
// You can pass options to `doFetch` to customize the request. All of the props from `fetch()`, such as `url`,
0 commit comments