I thought myself pretty savvy when it came to rxjs, but I cannot figure out what I'm doing wrong. I'm trying to learn ngrx by converting my user login to an effect. My effect is firing correctly and the correct token response is returned (validated by logging in the console) from my server, but the map operator never gets triggered in my effect.
Here is my effect code:
@Injectable()
export class UserEffects {
constructor(
private authService: AuthService,
private actions$: Actions
) { }
@Effect() loginUser$ = this.actions$
.ofType<userActions.LoginUserAction>(userActions.LOGIN_USER).pipe(
switchMap(action => this.authService.Login(action.payload)),
map(user => (new userActions.LoginUserSuccessAction(user)))
);
}
and the request in my service layer:
public Login(model: ILogin) {
return this.http.post<string>(`${baseUrl}api/login`, model).pipe(
// Returns the object to be stored in AppState
map(response => this.GetTokenInformation(response))
);
}
I have tried using flatMap and mergeMap in case I was missing something in the ngrx documention but neither of those worked either.
my operators are being imported like so:
import { map, switchMap } from 'rxjs/operators';
let me know if i can provide anything else...thanks!