AjaxResource
Rest API Resource data fetcher
- enables crossdomain requrests
- enables CORS credentials (sends cookies)
- uses classic
GET/PUT/POST/DELETE
endpoints
Constructor Summary
Public Constructor | ||
public |
constructor(apiUrl: string, ajaxOptions: object, requestor: any) Creates an instance of AjaxResource. |
Member Summary
Public Members | ||
public |
Map response data after |
|
public |
mapGetOutput: * Map response data after |
|
public |
mapInput: * Map body data before |
|
public |
mapParams: * Map query params called before |
Method Summary
Public Methods | ||
public |
abort() Cancels current request |
|
public |
create(formData: Object): Promise<Object> Send data to server |
|
public |
getAll(params: Object): Promise<{data: [], offset: number, nextOffset: mumber}>{data:> Fetch all data |
|
public |
getById(id: string): Promise<Object> Get Single Element Data |
|
public |
getId(data: object): string Returns identifier of the object |
|
public |
remove(id: string): Promise Remove data by id |
|
public |
update(id: string, formData: Object): Promise<Object> Update data on server |
Public Constructors
public constructor(apiUrl: string, ajaxOptions: object, requestor: any) source
Creates an instance of AjaxResource.
Params:
Name | Type | Attribute | Description |
apiUrl | string | resource url |
|
ajaxOptions | object |
|
options passed to $.ajax |
requestor | any |
|
alternative to $.ajax |
Public Members
Public Methods
public create(formData: Object): Promise<Object> source
Send data to server
Params:
Name | Type | Attribute | Description |
formData | Object |
Return:
Promise<Object> |
public getAll(params: Object): Promise<{data: [], offset: number, nextOffset: mumber}>{data:> source
Fetch all data
Params:
Name | Type | Attribute | Description |
params | Object |
Return:
Promise<{data: [], offset: number, nextOffset: mumber}>{data:> |
public getById(id: string): Promise<Object> source
Get Single Element Data
Params:
Name | Type | Attribute | Description |
id | string |
Return:
Promise<Object> |
public getId(data: object): string source
Returns identifier of the object
Params:
Name | Type | Attribute | Description |
data | object |
Return:
string |
public remove(id: string): Promise source
Remove data by id
Params:
Name | Type | Attribute | Description |
id | string |
Return:
Promise |
public update(id: string, formData: Object): Promise<Object> source
Update data on server
Params:
Name | Type | Attribute | Description |
id | string | ||
formData | Object |
Return:
Promise<Object> |