Search code examples
angularinterfaceclienthttpresponseobservers

Could Not find HttpObserve from '@angular/common/http/src/client' after upgrading to angular 8


import { HttpObserve } from '@angular/common/http/src/client';
import { HttpParams, HttpHeaders } from '@angular/common/http';

type responseType = 'arraybuffer' | 'blob' | 'json' | 'text';

export interface RequestOptions {
  body?: any;
  headers?: HttpHeaders;
  params?: HttpParams;
  observe?: HttpObserve;
  reportProgress?: boolean;
  responseType?: responseType;
  withCredentials?: boolean;
}

The above code throws below mentioned error after upgrading to angular 8, any help ?

error TS2307: Cannot find module '@angular/common/http/src/client'.


Solution

  • Angular update guide says:

    If you use the legacy HttpModule and the Http service, switch to HttpClientModule and the HttpClient service. HttpClient simplifies the default ergonomics (you don't need to map to JSON anymore) and now supports typed return values and interceptors. Read more on angular.io.