redux-saga-thunk
redux-saga-thunk copied to clipboard
Header 200, empty body = Unexpected end of JSON input
middleware.js:22 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
Even though the request passed and received a 200 header code. The body is empty, though, and this makes an error in redux-saga-thunk
More info on this, appears to come as a result of redux api always assuming a response is json
https://github.com/diegohaz/arc/blob/redux/src/services/api/index.js#L16
i can submit a PR later
API should really be returning a 204 in that instance ;) but yes, I have this same issue with vanilla fetch when you encounter an empty 200
If anyone else encounters this, I’ve edited my version of that line to read:
export const parseJSON = response => {
if (response.status == 204) return {}
return response.json()
}