Kind: Class
Source: Pams/Web/Pams.WebApp/Client/app/core/services/api/base-api.service.ts (line 12)
Part of: Pams
BaseApiService is a generic base class for client-side API calls that return RxJS Observable values. It groups collection retrieval, item retrieval, deletion, saving, ID generation, and error handling for application services.
Implements: IApi
Methods
| Method | Signature | Returns |
|---|---|---|
get | get(queryParams: any[]) | Observable<T[]> |
getById | getById(id: number) | Observable<T> |
delete | delete(id: number) | Observable<{}> |
save | save(item: T, queryParams: any[]) | Observable<T> |
getNewId | getNewId() | void |
handleError | handleError(error: Response) | void |
Properties
| Property | Type |
|---|---|
keyName | string |
resourceName | string |
headers | any |
headersPost | any |
basePath | any |
entity | T |
Diagram
mermaidgraph LR Consumer[Component or Service] --> BaseApiService BaseApiService --> Get[get] BaseApiService --> GetById[getById] BaseApiService --> Save[save] BaseApiService --> Delete[delete] BaseApiService --> NewId[getNewId] BaseApiService --> Error[handleError] Get --> Observable GetById --> Observable Save --> Observable Delete --> Observable
Usage
tsimport { BaseApiService } from './core/services/api/base-api.service';
interface Project {
id: string;
name: string;
}
declare const projectApi: BaseApiService<Project>;
projectApi.get().subscribe({
next: (projects) => console.log(projects),
error: (error) => console.error(error)
});
projectApi.save().subscribe({
next: (project) => console.log(project),
error: (error) => console.error(error)
});
AI Coding Instructions
- Extend
BaseApiServicewith the domain model type for each API resource. - Keep API method return values as
Observablevalues; subscribe in components or other consumer boundaries. - Follow the existing
get,getById,save, anddeletemethods instead of duplicating request and error-handling logic. - Keep resource-specific endpoint configuration and model mapping in the service that extends this class.
Used by
50 references from 50 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (50)
BaseEdit—Pams/Web/Pams.WebApp/Client/app/core/components/base-edit.component.ts:1CoreModule—Pams/Web/Pams.WebApp/Client/app/core/core.module.ts:1AddressTypeService—Pams/Web/Pams.WebApp/Client/app/services/common/address-type.service.ts:1AddressService—Pams/Web/Pams.WebApp/Client/app/services/common/address.service.ts:1BookingTargetService—Pams/Web/Pams.WebApp/Client/app/services/common/booking-target.service.ts:1CategoryService—Pams/Web/Pams.WebApp/Client/app/services/common/category.service.ts:1CityService—Pams/Web/Pams.WebApp/Client/app/services/common/city.service.ts:1ClientTypeService—Pams/Web/Pams.WebApp/Client/app/services/common/client-type.service.ts:1
…and 42 more.
Was this page helpful?