Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

No overload matches this call. angular2 to angular12

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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 })
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading