Reputation: 39
How to get data from below HTTP request.
srp/dashboard/graphics-chart/v1/{roleId}.
In webservice.url.ts I decalred a variable ang assigned the URL to it.
dashboardbardata : 'srp/dashboard/graphics-chart/v1/'.
there is already get req done below is code and file name is apiservice.ts
get(path: string, params: HttpParams = new HttpParams()): Observable<any> {
return this.http.get(`${environment.api_url}${path}`, { params })
.pipe(catchError(this.formatErrors));
}
How to use the above HTTP request in my service file and how to subscribe it in TS file.
Upvotes: 0
Views: 38
Reputation: 758
in service webservice.url.ts
public getData(roleId) {
return this.apiService.get(roleId);
}
in dashboard
service.getData(roleId).subscribe((res: any) {
// your code
});
Upvotes: 1