View
The JSON API View enhances the datx
view with the following properties and methods:
sync
sync<T extends IJsonapiModel = IJsonapiModel>(body?: IResponse): T|Array<T>|null;
Add the data from a JSON API response to the view. The return value is a model or an array of models from the JSON API data
property.
fetch
fetch<T extends IJsonapiModel = IJsonapiModel>(id: number|string, options?: IRequestOptions): Promise<Response<T>>;
Fetch a single model from the server.
The options can be used to send additional parameters to the server.
If an error happens, the function will reject with the Response
object with the error
property set.
fetchAll
fetchAll<T extends IJsonapiModel = IJsonapiModel>(options?: IRequestOptions): Promise<Response<T>>
Fetch multiple models of the view type from the server. This will either be all models or a first page of models, depending on the server configuration. When requesting other pages with the response getters, they will also be added to the view automatically.
The options can be used to send additional parameters to the server.
If an error happens, the function will reject with the Response
object with the error
property set.