I have two recommended ways of doing an Angular API call.
Both of them work but I am
trying to understand the difference. Any insight would be appreciated...
Here is the
first option.
public get(url: string, options?: any) {
return this.http.get(url, options);
}
Open in new window
This is the
second option.
public get(url: string, options?: any) {
return this.http.get(url, options)
.pipe(map(getdata => {
console.log("apiSvc.19 | get RETURN: ",getdata);
return getdata;
}),
catchError(this.handleError('api-http-svsc.27 | API for getURL ['+url+']', options)));
}
Open in new window