I write ngrx effect with httpRequest which use action.payload of Action.
From request I get data which I use in map operator (if error occur i handle it in catchError)
From Backend I get only boolean value, How I can propagate action.payload from Action to map or catchError operator?
Example:
effect= this.actions$
.ofType(Actions.IS_OK)
.pipe(
mergeMap(action => this.service.isOk(action.payload),
map((isOk: boolean) => new SuccessAction(isOk, action.payload), //here I need somehow get to action.payload value
catchError(error => of(new ErrorAction(error, action.payload))) //here I need somehow get to action.payload value
);
And I can not store payload to store, because I have triggered more actions: Actions.IS_OK
Thanks for help
Can you try :
effect = this.actions$
.ofType(Actions.IS_OK)
.pipe(
mergeMap(action => this.service.isOk(action.payload).pipe(
map((isOk: boolean) => { payload: action.payload, isOk: isOk} )
),
// need to create proper interface forPayload + isOk
map((payloadPlusIsOk: any) => new SuccessAction(payloadPlusIsOk.isOk, payloadPlusIsOk.payload),
catchError(error => of(new ErrorAction(error, action.payload))) //here I need somehow get to action.payload value
);