Jefferson
Jefferson

Reputation: 67

Angular replaced @angular/http with @angular/common/http

I am in the process of upgrading my project and need to change my api from @angular/http to @angular/common/http. I main question do I just need to change the import or will the code need to change?

Old Version Code import { Http, Response, URLSearchParams, Headers } from "@angular/http";

getGridPage(gridQueryData: OrderTemplateTool.Core.Models.Grid.GridQueryData): Promise<Response> {
    return this.http.post(this.apiUrls.GetGridPage, JSON.stringify(gridQueryData), { headers: ServiceBase.headers }).toPromise();
}

New import for package has been deprecated

import { HttpClient, Response, URLSearchParams, Headers } from "@angular/common/http";

Upvotes: 0

Views: 1023

Answers (1)

Chip
Chip

Reputation: 268

I recently went through this and found the code I was using worked fine once I updated the import. HttpClient, Response, URLSearchParams, Headers should work the same with the new import.

Upvotes: 1

Related Questions