Angular 4 HttpClient Query Parameters

I have been looking for a way to pass query parameters into an API call with the new HttpClientModule‘s HttpClient and have yet to find a solution. With the old Http module you would write something like this. getNamespaceLogs(logNamespace) { // Setup log namespace query parameter let params = new URLSearchParams(); params.set(‘logNamespace’, logNamespace); this._Http.get(`${API_URL}/api/v1/data/logs`, { … Read more

Adding a HTTP header to the Angular HttpClient doesn’t send the header, why?

Here is my code: import { HttpClient, HttpErrorResponse, HttpHeaders } from ‘@angular/common/http’; logIn(username: string, password: string) { const url=”http://server.com/index.php”; const body = JSON.stringify({username: username, password: password}); const headers = new HttpHeaders(); headers.set(‘Content-Type’, ‘application/json; charset=utf-8’); this.http.post(url, body, {headers: headers}).subscribe( (data) => { console.log(data); }, (err: HttpErrorResponse) => { if (err.error instanceof Error) { console.log(‘Client-side error occured.’); … Read more