是否可以将reportProgress与http.post一起使用? Angular在其HttpClient部分(https://angular.io/guide/http)中的http请求设置不同 我的服务提供商设置如下:
postForm(shortForm: any): Observable<ShortFormModel> {
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({
headers: headers
});
return this.http.post(this.preCheckUrl, shortForm, options)
.map((res) => this.extractData(res))
.catch(
(error: any): Promise<any>=> {
console.error('An error occurred', error);
this.router.navigate(['/error', error]);
return Promise.reject(error.message || error);
}
)
}
private extractData(res: Response) {
let body = res.json();
return body || { };
}
我尝试在选项中添加reportProgress: true
,但收到错误:Argument of type '{ headers: Headers; reportProgress: boolean; }' is not assignable to parameter of type 'RequestOptionsArgs'.
Object literal may only specify known properties, and 'reportProgress' does not exist in type 'RequestOptionsArgs'.