Skip to content

Commit bee08a7

Browse files
author
Alex Cory
committed
Merge branch 'master' of github.com:alex-cory/react-usefetch
2 parents 49bc8e6 + c961456 commit bee08a7

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ This is exactly what you would pass to the normal js `fetch`, with a little extr
781781
| Option | Description | Default |
782782
| --------------------- | --------------------------------------------------------------------------|------------- |
783783
| `cacheLife` | After a successful cache update, that cache data will become stale after this duration | `0` |
784-
| `cachePolicy` | These will be the same ones as Apollo's [fetch policies](https://www.apollographql.com/docs/react/api/react-apollo/#optionsfetchpolicy). Possible values are `cache-and-network`, `network-only`, `cache-only`, `no-cache`, `cache-first`. Currently only supports **`cache-first`** or **`no-cache`** | `cache-first` |
784+
| `cachePolicy` | These will be the same ones as Apollo's [fetch policies](https://www.apollographql.com/docs/react/api/react/hoc/#optionsfetchpolicy). Possible values are `cache-and-network`, `network-only`, `cache-only`, `no-cache`, `cache-first`. Currently only supports **`cache-first`** or **`no-cache`** | `cache-first` |
785785
| `data` | Allows you to set a default value for `data` | `undefined` |
786786
| `interceptors.request` | Allows you to do something before an http request is sent out. Useful for authentication if you need to refresh tokens a lot. | `undefined` |
787787
| `interceptors.response` | Allows you to do something after an http response is recieved. Useful for something like camelCasing the keys of the response. | `undefined` |
@@ -808,7 +808,7 @@ const options = {
808808

809809
// Cache responses to improve speed and reduce amount of requests
810810
// Only one request to the same endpoint will be initiated unless cacheLife expires for 'cache-first'.
811-
cachePolicy: 'cache-first' // 'no-cache'
811+
cachePolicy: 'cache-first', // 'no-cache'
812812

813813
// set's the default for the `data` field
814814
data: [],

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ This is exactly what you would pass to the normal js `fetch`, with a little extr
734734
| Option | Description | Default |
735735
| --------------------- | --------------------------------------------------------------------------|------------- |
736736
| `cacheLife` | After a successful cache update, that cache data will become stale after this duration | `0` |
737-
| `cachePolicy` | These will be the same ones as Apollo's [fetch policies](https://www.apollographql.com/docs/react/api/react-apollo/#optionsfetchpolicy). Possible values are `cache-and-network`, `network-only`, `cache-only`, `no-cache`, `cache-first`. Currently only supports **`cache-first`** or **`no-cache`** | `cache-first` |
737+
| `cachePolicy` | These will be the same ones as Apollo's [fetch policies](https://www.apollographql.com/docs/react/api/react/hoc/#optionsfetchpolicy). Possible values are `cache-and-network`, `network-only`, `cache-only`, `no-cache`, `cache-first`. Currently only supports **`cache-first`** or **`no-cache`** | `cache-first` |
738738
| `data` | Allows you to set a default value for `data` | `undefined` |
739739
| `interceptors.request` | Allows you to do something before an http request is sent out. Useful for authentication if you need to refresh tokens a lot. | `undefined` |
740740
| `interceptors.response` | Allows you to do something after an http response is recieved. Useful for something like camelCasing the keys of the response. | `undefined` |

src/doFetchArgs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function doFetchArgs<TData = any>(
5353

5454
const headers = ((): HeadersInit | null => {
5555
const contentType = ((initialOptions.headers || {}) as any)['Content-Type']
56-
const shouldAddContentType = !!contentType || [HTTPMethod.POST, HTTPMethod.PUT].includes(method) && !(body instanceof FormData)
56+
const shouldAddContentType = !!contentType || [HTTPMethod.POST, HTTPMethod.PUT, HTTPMethod.PATCH].includes(method) && !(body instanceof FormData)
5757
const headers: any = { ...initialOptions.headers }
5858
if (shouldAddContentType) {
5959
// default content types http://bit.ly/2N2ovOZ

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export enum HTTPMethod {
1111
PUT = 'PUT',
1212
}
1313

14-
// https://www.apollographql.com/docs/react/api/react-apollo/#optionsfetchpolicy
14+
// https://www.apollographql.com/docs/react/api/react/hoc/#optionsfetchpolicy
1515
export enum CachePolicies {
1616
/**
1717
* This is the default value where we always try reading data

0 commit comments

Comments
 (0)