In Typescript/Angular 6 (2+), is it considered a good practice to have a base abstract http service from which derives all the application services? for example:
//import the angular Http ...etc
export abstract class MyBaseService{
...
protected get<T>(url: string): Observable<T> {
return this.http.get(...)
.pipe(map(result => result.json() as T));
}
protected post<T>....
...
}
We basically define all the rest methods (GET, POST, PUT, .. etc)
And then we have every service extend the base one:
export class MyFirstService extends MyBaseService{
...
public doWork(data: MyModel): Observable<string> {
this.post<string>(`my url`, data);
}
...
}