I am using Angular NGRX for state management in my angular application. On dispatching login action i receives CognitoUser object from my login service as i am using AWS amplify service.
When i dispatch LoginSuccess action to pass this object i receives error TypeError: Cannot freeze. Login Success action is dispatched but data object is not received in reducer.
Here is my effect code
export class LoginEffects {
login$ = createEffect(() =>
this.actions$.pipe(
ofType(LoginActions.login),
switchMap((action) =>
from(this.authService.login(action.username, action.password))
),
catchError((error) => of(LoginActions.loginError(error))),
map((user) => LoginActions.loginSuccess(user))
)
);
// ... other effects
constructor(
private actions$: Actions,
private authService: AuthService,
private router: Router
) {}
}
However if i assign this response user into another object like this
const obj = { ...user };
Then i am receiving data in reducer but in case of CognitoUser object i am not receiving data in reducer.
How can i pass CognitoUser object in reducer?
from Angular NGRX cannot pass data to reducer when dispatching action from effect. Got Error - TypeError: Cannot freeze
No comments:
Post a Comment