My issue seems to be related to the error message "Actions must have a type property". It appears that the problem lies with my RegisterSuccess action, but after searching on SO, I discovered that it could be due to how I am invoking it. I've tried some of the suggested solutions from other sources, but they haven't resolved the issue in my particular case.
Effect:
@Effect()
register = this.actions$.pipe(
ofType(AuthActionTypes.REGISTER),
switchMap(action => this.auth.register(action.registration).pipe(
map(result => ([
{ type: AuthActionTypes.REGISTER_SUCCESS, user: result }
])),
catchError(result => ([
{ type: AuthActionTypes.REGISTER_FAIL }
])),
))
);
Action:
export class Register implements Action {
readonly type = AuthActionTypes.REGISTER;
constructor(public registration: Registration) {}
}
export class RegisterSuccess implements Action {
readonly type = AuthActionTypes.REGISTER_SUCCESS;
constructor(public user: User) {}
}
export class RegisterFail implements Action {
readonly type = AuthActionTypes.REGISTER_FAIL;
constructor() {}
}
Service:
register(user: Registration): Observable<any> {
return this.api.post('auth/register', user).pipe(map(res => res.data));
}