RXJS 6中的退货承诺

时间:2019-01-28 11:59:06

标签: angular ionic-framework

所以我刚刚升级到RXJS 6,但是有这个小问题。

 getProfile(credentials) {
    return new Promise((resolve, reject) => {
      this.http.get('admin/userstatus-auth', {credentials}).pipe(
        map(res => res))
          .subscribe(res => {
            resolve(res);
          }, (err) => {
            reject(err);
          });
    });
  }

因此在这里它表示以下内容:

Argument of type ‘{credentials : any}’ is not assignable to parameter of type ‘{headers?: HttpHeaders }’

enter image description here

如果我执行“凭据:HttpHeaders”,则会收到相同的错误

1 个答案:

答案 0 :(得分:0)

尝试一下。

 getProfile(credentials) {

    const params = new HttpParams().set('credentials', credentials);
    return new Promise((resolve, reject) => {
      this.http.get('admin/userstatus-auth', { params: params }).pipe(
        map(res => res))
          .subscribe(res => {
            resolve(res);
          }, (err) => {
            reject(err);
          });
    });
}