I use HttpParams in an HTTP get request of my Angular 7.2.0 application. After I building the project using "ng build --extract-css --aot" command, run the application and log the HttpParams value on the console, I can see the parameter value on the console, but it is not reflected in the http request on the network tab. Please advise me on this.
This solution works fine in Chrome, I am getting this issue only when I am using IE.
I tried the same approach with and without "application/json" headers, but no difference.
I tried this with all the polyfills enabled, it didn't fix the issue either.
analytics.service.ts
import { ErrorsService } from 'src/app/shared/services/errors.service';
import { Observable } from 'rxjs';
import { Activity } from 'src/app/models/Activity';
import { HttpParams, HttpClient, HttpHeaders } from '@angular/common/http';
import { catchError } from 'rxjs/operators';
@Injectable()
export class AnalyticsService {
routePrefix = 'api/analytics';
constructor(private http: HttpClient, private errorsService: ErrorsService) { }
public getSessionActivities(duration): Observable<Activity[]> {
let headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
const requestParams = new HttpParams().set('duration', duration);
console.log("---Get Session Activities---", requestParams);
return this.http.get<Activity[]>(this.routePrefix, { headers: headers, params: requestParams }).pipe(
catchError(err => this.errorsService.handleError(err))
);
}
}
import { Injectable } from '@angular/core';
import { ErrorsService } from 'src/app/shared/services/errors.service';
import { Observable } from 'rxjs';
import { Activity } from 'src/app/models/Activity';
import { HttpParams, HttpClient, HttpHeaders } from '@angular/common/http';
import { catchError } from 'rxjs/operators';
@Injectable()
export class AnalyticsService {
routePrefix = 'api/analytics';
constructor(private http: HttpClient, private errorsService: ErrorsService) { }
public getSessionActivities(duration): Observable<Activity[]> {
let headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
const requestParams = new HttpParams().set('duration', duration);
console.log("---Get Session Activities---", requestParams);
return this.http.get<Activity[]>(this.routePrefix, { headers: headers, params: requestParams }).pipe(
catchError(err => this.errorsService.handleError(err))
);
}
}