I'm passing some data as query string parameter as POST method in Angular8 using HttpParams. While checking the network tab the API is not formed with the query string parameters and the request header is also not correct. Kindly find the below code base and let me know if anyone has any inputs on this.
component.ts
this.data = {
id: 21
}
this.dataService.getData(this.data).subscribe(
response => {console.log(response);}
)
dataService.ts
getData(inputParam) {
const params = new HttpParams().set('roleId', inputParam.id);
return this.httpService.post('getDataList', {params});
}
httpService.ts
post(api: string, request: any): Observable <any> {
return this.http.post<any>(api,request);
}
while checking the network tab the api is showing like below
getDataList
we need the api with query parameter as below
getDataList?roleId=21
The above code is working fine while testing with another GET method only issue is with this POST method. Do we need to set the headers manually for the POST method? Can anyone help on this issue.