I try to handle Unauthorized error from server using redux-saga. This is my saga:
function* logIn(action) {
try {
const user = yield call(
if you want to have that if statement verifying the response status if(res.status >= 200 && res.status < 300) { you need to have it inside your first promise where res is defined, it's currently inside the resolved promise for res.json()
.then(res => {
if (res.status >= 200 && res.status < 300) {
res.json().then(json => {
return json
}
})
})