Service API needs prettier structure
jhcao23 opened this issue · comments
Improvement needed for Service Layer
In Service layer, something like return this.http.post('https://api.com', { body: param })
:
- first of all we might want to refer
https://api.com
to some const fromenvironment.ts
such asURL_REST_API
. - for each service CRUD method, the template could possibly provide a default path after the
URL_REST_API
such as GET, CREATE, UPDATE, DELETE; then an example ofaddXXX
might look like this:
addXXX(param: any): Observable<any> {
return this.http.post(`${environment.URL_REST_API}/ADD`, { body: param });
}
- can we avoid the 'too general' parameter type
(param: any)
and use the actual target typeXXX
? - anyways, I feel the services still have room to improve. I will try to find a time to contribute on coding rather than talking.
Thanks,
John