Skip to content

Commit 7466e13

Browse files
author
Alex Cory
committed
Merge branch 'master' of github.com:alex-cory/react-usefetch
2 parents e1ce6fa + cea059e commit 7466e13

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ var {
328328
patch,
329329
delete // don't destructure `delete` though, it's a keyword
330330
del, // <- that's why we have this (del). or use `request.delete`
331+
head,
332+
options,
333+
connect,
334+
trace,
331335
mutate, // GraphQL
332336
query, // GraphQL
333337
abort

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ var {
309309
patch,
310310
delete // don't destructure `delete` though, it's a keyword
311311
del, // <- that's why we have this (del). or use `request.delete`
312+
head,
313+
options,
314+
connect,
315+
trace,
312316
mutate, // GraphQL
313317
query, // GraphQL
314318
abort

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export enum HTTPMethod {
99
PATCH = 'PATCH',
1010
POST = 'POST',
1111
PUT = 'PUT',
12+
CONNECT = 'CONNECT',
13+
TRACE = 'TRACE'
1214
}
1315

1416
// https://www.apollographql.com/docs/react/api/react/hoc/#optionsfetchpolicy

src/useFetch.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function useFetch<TData = any>(...args: UseFetchArgs): UseFetch<TData> {
105105
if (response.isCached && cachePolicy === CACHE_FIRST) {
106106
newRes = response.cached as Response
107107
} else {
108-
newRes = await fetch(url, options)
108+
newRes = (await fetch(url, options)).clone()
109109
}
110110
res.current = newRes.clone()
111111

@@ -208,6 +208,10 @@ function useFetch<TData = any>(...args: UseFetchArgs): UseFetch<TData> {
208208
post,
209209
patch: makeFetch(HTTPMethod.PATCH),
210210
put: makeFetch(HTTPMethod.PUT),
211+
options: makeFetch(HTTPMethod.OPTIONS),
212+
head: makeFetch(HTTPMethod.HEAD),
213+
connect: makeFetch(HTTPMethod.CONNECT),
214+
trace: makeFetch(HTTPMethod.TRACE),
211215
del,
212216
delete: del,
213217
abort: () => controller.current && controller.current.abort(),

0 commit comments

Comments
 (0)