Hi I am trying to pass parameter in POST method url in angular service to construct a URL to fetch some data from an API but when I am calling it on component file I am getting error response.
Where am I doing wrong ?
Example I need this type of url to pass:- https://something/api/v1/map/GetdetailsById?ID=EF-345-RHDJI34-EHI3
In service I am doing :-
// Http Options
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
//POST API to show lists
getOTList(): Observable<any> {
const params = new HttpParams()
.set('ID', 'EF-345-RHDJI34-EHI3');
return this.http
.post<any>(`${environment.Url}` + `${APIs.getList}`,{params}, this.httpOptions)
.pipe(
retry(1),
catchError(this.handleError)
)
}
Ang in component I am doing :
ngOnInit(){
this.getLists();
}
getLists(){
this.addService.getOTList().subscribe((response:any) => {
if (response.IsSuccess == true) {
console.log(response);
}
else {
console.log("something is wrong.") //<========== getting this message in console
}
});
}