【发布时间】:2018-11-20 21:18:02
【问题描述】:
使用redux和Angular,我有如下效果:
@Effect()
public authenticate: Observable<Action> = this.actions
.ofType(AUTHENTICATE)
.pipe(
map((action: AuthenticateAction) => action.payload),
switchMap(payload => {
return this.userService.authenticateUser(payload.email, payload.password).pipe(
map(auth => new AuthenticationSuccessAction({ auth: auth })),
catchError(error => of(new HttpErrorAction({ error: error })))
);
})
);
服务:
public authenticateUser(email: string, password: string): Observable<IAuthentication> {
const formData: FormData = new FormData();
formData.append('email', email);
formData.append('password', password);
return this.httpClient.post('/api/auths/useraccounts', formData) as Observable<IAuthentication>;
}
当 POST 失败时,永远不会调度 HttpErrorAction。
【问题讨论】:
标签: angular rest error-handling redux rxjs