从Angular 5.2升级到7个Break Post方法

时间:2019-02-05 14:24:24

标签: angular typescript http

  

类型'((error:HttpErrorResponse)=> void'的参数不是   可分配给类型'(err:any,catch:   Observable>)=> ObservableInput'。类型   不能将“ void”分配给“ ObservableInput”类型

xls

1 个答案:

答案 0 :(得分:0)

请尝试以下操作:

public GetFullAddress(addressModel: FullAddressLookupModel): Promise<AddressModel> {
    const promise: Promise<AddressModel> = new Promise<AddressModel>((resolve, reject) => {
        this.httpClient.post<AddressModel>(`${this.Domain}api/addressSearch/confirmAddressSelection`, JSON.stringify(addressModel), this.httpOptions ).pipe(
            catchError(this.handleError)
        )).toPromise().then((response) => {
            resolve(response);
        }, (err) => {
            reject(err);
        });
    });

    return promise;
}

出现以下错误 enter image description here