也许下面的代码可以按原样工作,但我不确定这是否是正确的实现,以防止运行时出现任何可能的问题。
拥有以下内容:
const ep = `${environment.api.baseUrl}/login`;
return this.http.post<ILoginResponse>(ep, request).pipe(map(req => {
this.storage.set(environment.storage_keys.token, req.access_token).then(() => {
this.authState$.next(true);
});
return req;
})).toPromise();
如果this.storage.set
返回异常或由于任何原因失败,我如何确保toPromise()
将被拒绝?
https://stackoverflow.com/questions/56449967
复制相似问题