0

我尝试创建自定义 Http 类以在全球范围内处理 401 错误。调用超级构造函数时出现错误 -参数类型 RequestOptions 不可分配给参数类型 RequestOptions

这是我的代码:

@Injectable()
export class HttpService extends Http {
  private baseUrl: string;

  constructor(baseUrl: string, backend: ConnectionBackend, options: RequestOptions) {
    this.baseUrl = baseUrl;
    super(backend, options); // <- Error here
  }

  get(url: string, options?: RequestOptionsArgs): Observable<Response> {
    console.log('get...');
    return super.get(this.baseUrl.concat(url), options).catch(this.handleError);
  }

  private handleError(error: Response | any) {
    console.log(error['status']);

    return Observable.throw(error);
  }
}
4

0 回答 0