-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
refactorMake things more beautiful inside, but same outsideMake things more beautiful inside, but same outside
Description
The fetchAPI middleware returns an object if the payload is of type JSON or nothing otherwise. The response object could be useful to performs some checks programmatically in the reducer, without having to rely on human-readable error details. The middleware should return an object containing the payload or nothing, and the response:
if (contentType !== "application/json") {
const outcome = {response}
if (!response.ok) return Promise.reject(outcome)
return outcome
}
return response.json().then(json => {
const outcome = {data: json, response}
if (!response.ok) return Promise.reject(outcome)
return outcome
}Metadata
Metadata
Assignees
Labels
refactorMake things more beautiful inside, but same outsideMake things more beautiful inside, but same outside