试图解决这个错误有什么提示吗?这是试图执行post请求的代码,然后用解析的数据调用操作。
export class AuthEffects {
authLoging= createEffect(
()=> this.actions$.pipe(
ofType(authActions.LOGIN_START),
switchMap((authData:authActions.LoginStart)=>
this.http.post<authResponse>('https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + environment.FireBasekey,
{
email: authData.payload?.email,
password: authData.payload?.password,
returnSecureToken: true
}).pipe(map(resData => {
return of(new authActions.Login({
email: resData.email,
userId: resData.localId,
token: resData.idToken,
expirationDate: new Date(new Date().getTime() + +resData.expiresIn * 1000)
}))
})
)
)
)
);
constructor(private actions$: Actions , private http:HttpClient){}}
类型“可观察”不能指定为键入“EffectResult”。类型‘可观察’是不能分配的类型‘可观察’。属性“type”在“可观察”类型中缺失,但在类型“Action”中是必需的。
发布于 2021-03-10 10:13:08
删除map()中的of():
}).pipe(map(resData => {
return new authActions.Login({地图操作员已经把它包在一个可以观察到的地方了。
你还必须按效果返回一个动作。
另一个提示:在同一个管道中添加一个catchError,否则如果HttpCall失败一次,您的效果就会终止。
发布于 2021-03-10 00:13:20
当我从这里移除操作符时,它将立即返回一个新实例。
return of(new authActions.Login({
email: resData.email,
userId: resData.localId,
token: resData.idToken,
expirationDate: new Date(new Date().getTime() + +resData.expiresIn * 1000)
}))https://stackoverflow.com/questions/66556017
复制相似问题