有人能帮忙吗(对rxjs缺乏了解(我需要一个接一个地调用1个API,传递部分相同的参数,但不知道如何做到这一点。代码中应该很清楚。提前感谢
const MyEpic = (action$) =>
action$.pipe(
ofType(constants.QWERTY_REQUEST),
switchMap((action) =>
from(
myApi1.checkCredentials(action.payload.userName, action.payload.password)
).pipe(
map((action) => {
return ({type: constants.QWERTY_SUCCESS, payload: action.payload.userName})}), //at this point there is no action.payload.userName how to get initial payload???
catchError(() => {
return of(...);
})
)
)
action
参数被遮蔽。如果需要访问父作用域中具有相同名称的参数,则名称应不同:
map((whatever) => {
return ({type: constants.QWERTY_SUCCESS, payload: action.payload.userName})}),
...