Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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