Under my Angular 6 application, I am attempting to make a GET request while injecting some custom Headers:
Here is how my service is structured:
@Injectable()
export class MyService {
constructor(public httpClient: HttpClient) {
}
getUserInfos(login): Observable<any> {
const headers = new HttpHeaders({'login': login});
return this.httpClient.get(environment.urls.UserHabilitation, {headers});
}
And in my Component, I handle the subscription as follows:
this.myService.getUserInfos(login).subscribe(infos => {
console.log(infos);
error => {
console.log(error);
});
The above code works correctly in Firefox, but encounters issues in Chrome and IE11. The error message received is:
TypeError: Cannot read property 'length' of null at HttpHeaders.push../node_modules/@angular/common/fesm5/http.js.HttpHeaders.applyUpdate (http.js:199) at http.js:170 at Array.forEach () at HttpHeaders.push../node_modules/@angular/common/fesm5/http.js.HttpHeaders.init (http.js:170) at HttpHeaders.push../node_modules/@angular/common/fesm5/http.js.HttpHeaders.forEach (http.js:235) at Observable._subscribe (http.js:1445) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28) at subscribeTo.js:21 at subscribeToResult (subscribeToResult.js:6)
Any suggestions on resolving this issue?