I'm using redux thunk to fetch some data in an action
function handleErrors(response) {
console.log(response)
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
export const something = (var) => dispatch => {
fetch(`${url}/something`, {credentials: 'include'})
.then(handleErrors)
.then(res => res.json())
.then(res =>
dispatch({
type: SOMETHING,
payload: res
})
)
.catch(error =>
dispatch({
type: ERROR,
payload: error
})
)
my express server on an error responds with 'some error'
return res.status(500).send({ message: 'some error' });
when it fetches and it's an error (500), its message is the generic "Internal Server Error".
how do I get the 'some error' in fetch?