restangular
restangular copied to clipboard
fix(service): Custom getRestangularUrl() and getRequestUrl() - #1216
fix(service): Custom getRestangularUrl() and getRequestUrl() - #1216
@nonplus Thanks! Can you describe what this PR is about and why we need it?
It addresses the problem described in #1216.
Personally, I want to be able to (periodically) re-fetch a Restangular resource. I should be able to do something like this:
RestangularProvider.setOnElemRestangularized((elem, isCollection) => {
if (!isCollection) {
elem["fetch"] = function() {
return this.get(this.reqParams);
};
elem["refresh"] = function() {
return this.fetch()
.then(value => angular.copy(value, this));
};
}
return elem;
});
This works fine for one/all resources, but doesn't work for resources returned by customGET("path") or methods added via addRestangularMethod("methodName", "GET", "path") because Restangular incorrectly doesn't include "path" in the URL used by get().