I have implemented a signup view with backend validation, and I want to redirect to Login view after successfull signup. Here is my dispatching method:
export const initSignup = (details) => {
return (dispatch) => {
axios.post("http://localhost:8080/auth/signup", {
email: details.email,
password: details.password
}).then((result) => {
console.log(result);
return dispatch(_signup(result));
})
.catch((err) => {
//use err.response to get our custom err response from backend
//since once we send 400+ response status it goes to catch block
console.log(err);
dispatch(_signupError(err.response));
})
}
}
const _signup = (result) => {
return {
type: SIGNUP,
result: result
}
}
const _signupError = (err) => {
return {
type: ERROR,
error: err
}
}
After disptach _signup I want to redirect to "/login". Can someone help me here.