I want to logout the user immediately after login , so I could see in redux if It works and I get this error: Uncaught Error: Actions may not have an undefined "type" property. Have you misspelled a constant?
I should get AUTH_LOGOUT action in my redux after the success- example image . As I understand the error Is in the checkAuthTimeout:
export const checkAuthTimeout = (expirationTime) => {
return dispatch => {
setTimeout(() => {
dispatch(logout())
}, expirationTime )
}}
My logout:
export const logout = () => {
return {
type: actionTypes.AUTH_LOGOUT
}}
And auth:
export const auth = (email, password) => {
return dispatch => {
dispatch(authStart());
const authData = {
email:email,
password:password,
returnSecureToken: true
}
axios.post('https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaSyCpqBy-KjAJWCMUYLHVWAIu_HWZd3yzHVE', authData)
.then(response => {
console.log(response);
dispatch(authSuccess(response.data.idToken, response.data.localId));
dispatch(checkAuthTimeout(response.data.expiresIn));
})
.catch(err => {
dispatch(authFail(err.response.data.error));
});
}}
The error itself is pretty clear, your action type has value of undefined. Meaning actionTypes.AUTH_LOGOUT is undefined.
Try do a console.log on actionTypes.AUTH_LOGOUT, probably it's not defined or not imported properly. Show us the file where it is defined and imported, but I am positive the problem is either on how you exported or imported it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.