Home > OS >  No overload matches this call. angular2 to angular12
No overload matches this call. angular2 to angular12

Time:11-09

I am getting error in JSON.springify after I changed Headers to HttpHeaders because I upgraded my angular from Angular-2 to Angular-12

This is the error I am getting.Can anyone tell me what to use instead of JSON.stringify of maybe there is some fix in it .Kindly help.I am stuck here!

I am upgrading my Angular-2 project to Angular-12 project and when I changed :

Before

import { Http, Response, Headers } from '@angular/http';

After

import { HttpClient, HttpResponse, HttpHeaders } from '@angular/common/http';

I am facing issue to use HttpHeaders in place of Headers You can see the images below. I am stuck here. Need some help.

CodePudding user response:

The problem is that you set body in a GET request which has no body!

You can use this code below, but you will have to change your backend to use queryParams:

 this.http.get('myurl', { params: dataObject })
  • Related