gpt4 book ai didi

typescript - 错误 TS2339 : Property 'do' does not exist on type 'Observable

转载 作者:搜寻专家 更新时间:2023-10-30 21:01:42 28 4
gpt4 key购买 nike

我使用的是 angular-5.x,一旦升级到 angular-6.x 及其对等依赖项(zone、rxjs 等)。

我开始面临以下错误

ERROR in src/app/xxx/apiConnection/auth.interceptor.ts(25,33): error TS2339: Property 'do' does not exist on type 'Observable>'. src/app/xxx/apiConnection/auth.interceptor.ts(30,31): error TS2339: Property 'do' does not exist on type 'Observable>'.

我的代码如下:

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log(req)
if(!req.headers.has('skip-interceptors')) {
let card = localStorage.getItem(LocalStoregeIdems.oAUTH_ACCESS_CARD)
, headers;
if (card) {
headers = req.headers.set('Authorization', card);
}

let clone = req.clone({
withCredentials: true,
headers
});
return next.handle(clone).do(event => {
console.log(event);
});
} else {
req.headers.delete('skip-interceptors');
return next.handle(req).do(event => {
console.log(event);
});
}
}

最佳答案

do 运算符在 rxjs6 中已重命名为 tap 运算符。

希望对你有帮助

关于typescript - 错误 TS2339 : Property 'do' does not exist on type 'Observable<HttpEvent<any>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50354207/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com