Skip to content

Commit 6bbbae2

Browse files
authored
Update useFetch.js
1 parent 11c7b29 commit 6bbbae2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/useFetch.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ export function useFetch(arg1, arg2) {
3636

3737
const fetchData = useCallback(method => async (fArg1, fArg2) => {
3838
let query = ''
39-
const fetchOptions = {}
4039
if (isObject(fArg1) && method.toLowerCase() !== 'get') {
41-
fetchOptions.body = JSON.stringify(fArg1)
40+
options.body = JSON.stringify(fArg1)
4241
} else if (baseUrl && typeof fArg1 === 'string') {
4342
url = baseUrl + fArg1
44-
if (isObject(fArg2)) fetchOptions.body = JSON.stringify(fArg2)
43+
if (isObject(fArg2)) options.body = JSON.stringify(fArg2)
4544
}
4645
if (typeof fArg1 === 'string' && typeof fArg2 === 'string') query = fArg2
4746

@@ -50,7 +49,6 @@ export function useFetch(arg1, arg2) {
5049
const response = await fetch(url + query, {
5150
method,
5251
...options,
53-
...fetchOptions
5452
})
5553
let data = null
5654
try {

0 commit comments

Comments
 (0)