【发布时间】:2019-03-16 14:02:27
【问题描述】:
我正在尝试从 Angular 5 升级到 Angular 6 并收到此错误:
src/app/services/http.service.ts(17,14) 中的错误:错误 TS2339: “可观察”类型上不存在属性“超时”。
我在 http.service.ts 中的代码:
import { throwError as observableThrowError, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { environment } from "environments/environment";
import { AppService } from 'app/app.service';
import { HttpClient } from '@angular/common/http';
@Injectable()
export class HttpService {
private baseUrl = environment.apiUrl;
constructor(private http: HttpClient, private appService: AppService) { }
public get(endpoint: string): Observable<any>{
return this.http.get(this.baseUrl + endpoint)
.timeout(this.appService.timeoutInterval)
.retryWhen(error => error.delay(this.appService.waitInterval)
.take(this.appService.numberOfRetries)
.concat(observableThrowError(new Error())))
.share();
}
}
我在这里错过了什么?
【问题讨论】:
-
我对我的回答做了一些修改。请看一看。
标签: angular angular5 angular6 rxjs5 rxjs6