Angular 2 - 参数类型RequestOptions不能分配给参数类型RequestOptions

时间:2016-12-18 19:11:07

标签: http angular service injectable

我尝试创建cutom Http类到全球范围内的hadle 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);
  }
}

0 个答案:

没有答案