Skip to content

Commit 561309b

Browse files
committed
Improve readability of parseResponse function.
1 parent c0434f5 commit 561309b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react-async/src/useAsync.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ const useAsync = (arg1, arg2) => {
156156

157157
const parseResponse = (accept, json) => res => {
158158
if (!res.ok) return Promise.reject(res)
159-
if (json === true || (json !== false && accept === "application/json")) return res.json()
160-
return res
159+
if (typeof json === "boolean") return json ? res.json() : res
160+
return accept === "application/json" ? res.json() : res
161161
}
162162

163163
const useAsyncFetch = (input, init, { defer, json, ...options } = {}) => {

0 commit comments

Comments
 (0)