有一些与此相关的问题。.但是我经历了所有,但是我的问题没有解决。基本上我是一个初学者,所以我无法跟踪问题。
这是我的特效:
readMsg$ = createEffect(() => this.actions$.pipe(
ofType(readMsg),
map(action => action.payload),
switchMap((reqPayload: MsgReadRequest) => {
return this.httpService.post('api/msgread', reqPayload)
.pipe(
map((resp: MsgReadResponse) => resp.message === 'ok' ?
readMsgSucess({payload: resp}) :
readMsgFailure({payload: resp}),
catchError((error: HttpErrorResponse) => of(error.message))
)
);
})
));
这些是我的动作:
export const readMsg = createAction('[Read] Msg in xl', props<{payload: NewsReadRequest}>());
export const readMsgSucess = createAction('[Read] Msg in xl', props<{payload: NewsReadResponse}>());
export const readMsgFailure = createAction('[Read] Msg in xl', props<{payload: NewsResponse}>());
export const htttpError = createAction('[Read] Msg in xl error', props<{payload: HttpErrorResponse}>());
答案 0 :(得分:2)
一个简单的错误.. 在“动作”中,我不应该提及相同的语句。.我只是更改了如下所示的动作,现在一切正常。
export const readMsg = createAction('[Read] Msg in xl', props<{payload: NewsReadRequest}>());
export const readMsgSucess = createAction('[Read] Msg in xl success', props<{payload: NewsReadResponse}>());
export const readMsgFailure = createAction('[Read] Msg in xl failure', props<{payload: NewsResponse}>());
export const htttpError = createAction('[Read] Msg in xl error', props<{payload: HttpErrorResponse}>());
答案 1 :(得分:0)
也许这可以帮助您
const accountMask = '40899810999999999999',