You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One example use will be: let clients = this.restangular.all("client").getList<Client>();
This will return a list of objects type Client class; including the rectangular method on it.
There is a condition that the Client class has to extent the Restangular class before made any call.
export class Client extends Restangular(){}
because get and getList are implemented in the Restangular class.
Other methods need to be changed to generics like:
put([queryParams, headers]): Does a put to the current element
post(subElement, elementToPost, [queryParams, headers]): Does a POST and creates a subElement. Subelement is mandatory and is the nested resource. Element to post is the object to post to the server
remove([queryParams, headers]): Does a DELETE. By default, remove sends a request with an empty object, which may cause problems with some servers or browsers. This shows how to configure RESTangular to have no payload.
head([queryParams, headers]): Does a HEAD
trace([queryParams, headers]): Does a TRACE
options([queryParams, headers]): Does a OPTIONS
patch(object, [queryParams, headers]): Does a PATCH
save()
This will be a nice feature to be implemented as Typescript use classes.
The text was updated successfully, but these errors were encountered:
Hi @victorsosa, unfortunately in current restangular stage I can't find a solution to add correctly typed structure. In general, it's related to the configurable property names. If you have any ideas how it can be performed I will be happy to discuss. PR's are always welcome
Hi,
I was thinking that we are missing in this API the Typescript Generics for the function that return the result object.
One example use will be:
let clients = this.restangular.all("client").getList<Client>();
This will return a list of objects type Client class; including the rectangular method on it.
There is a condition that the Client class has to extent the Restangular class before made any call.
export class Client extends Restangular(){}
because get and getList are implemented in the Restangular class.
Other methods need to be changed to generics like:
This will be a nice feature to be implemented as Typescript use classes.
The text was updated successfully, but these errors were encountered: