Answer the question
In order to leave comments, you need to log in
How to handle c api error in redux thunk?
There is an api written in Laravel that returns a response with errors and with the corresponding code:
I send a request to the server in redux thunk and I want to return an error to the place from which dispatch was called
//Thunk
export const login = ({email,password,rememberMe}) => async(dispatch) => {
try{
dispatch(setLoading(true));
let response = await authapi.login(email, password, rememberMe);
if(response.data.status === 1){
//Какие то действия
}
}catch(e){
//Хочу обработать ошибку здесь ,но ошибка === undefined
console.log('login error', e);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question