Skip to content

Conversation

nonplus
Copy link

@nonplus nonplus commented Nov 21, 2016

fix(service): Custom getRestangularUrl() and getRequestUrl() - #1216

@bostrom
Copy link
Collaborator

bostrom commented Nov 21, 2016

@nonplus Thanks! Can you describe what this PR is about and why we need it?

@nonplus
Copy link
Author

nonplus commented Nov 21, 2016

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants