I'm trying to migrate my Http
requests to HttpClient
requests.
I was able to migrate my post
queries but I'm facing a problem while migrating get
queries. When I do so, my backend doesn't receive any parameters respectively, it tells me that the parameters are not provided and empty.
Did I do something wrong?
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
constructor(private httpClient: HttpClient) {}
findItems() {
let params: HttpParams = new HttpParams();
params.set('something', 'hello');
this.httpClient.get<any[]>('http://localhost:3000/apath/', {params})
.subscribe((results: any[]) => {
console.log(results);
}, (errorResponse: any) => {
console.error(errorResponse);
});
}
Any idea?