MCPcopy
hub / github.com/heroku/react-refetch / handleResponse

Function handleResponse

src/utils/handleResponse.js:3–15  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

1import newError from './errors'
2
3export default function handleResponse(response) {
4 if (response.headers.get('content-length') === '0' || response.status === 204) {
5 return
6 }
7
8 const json = response.json() // TODO: support other response types
9
10 if (response.status >= 200 && response.status < 300) { // TODO: support custom acceptable statuses
11 return json
12 } else {
13 return json.then(cause => Promise.reject(newError(cause)))
14 }
15}

Callers

nothing calls this directly

Calls 3

newErrorFunction · 0.85
thenMethod · 0.80
rejectMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…