Home > other >  Cannot find module '@angular/http/src/static_response' or its corresponding type declarati
Cannot find module '@angular/http/src/static_response' or its corresponding type declarati

Time:10-14

I'm getting an error Cannot find module '@angular/http/src/static_response' or its corresponding type declarations from my Angular v12 project when I try to use the import statement in my code: import { Response } from "@angular/http/src/static_response";. This statement was working perfectly fine in my Angular v4 project:

 getClientMasterData(): Observable<any> {
        return this.http.get(x.getBaseURL()   "/ClientMaster/GetMasterData", this.getHeader.get())
            .pipe(map((response: Response) => <MasterDataModel[]>response.json())
            ,catchError(this.handleError));
    }

While I know that http has been moved to @angular/common, I don't see neither src folder nor static_response file inside @angular/common.

Can someone please help?

CodePudding user response:

You'll need to do following changes:

  1. Replace import { Response } from "@angular/http/src/static_response"; with import { HttpResponse } from "@angular/common/http";
  2. Replace response: Response with response: HttpResponse<MasterDataModel[]>.
  • Related