Skip to content

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

Open
nonplus wants to merge 1 commit into
mgonto:masterfrom
nonplus:custom-urls
Open

fix(service): Custom getRestangularUrl() and getRequestUrl() - #1216#1439
nonplus wants to merge 1 commit into
mgonto:masterfrom
nonplus:custom-urls

Conversation

@nonplus

@nonplus nonplus commented Nov 21, 2016

Copy link
Copy Markdown

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

@bostrom

bostrom commented Nov 21, 2016

Copy link
Copy Markdown
Collaborator

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

@nonplus

nonplus commented Nov 21, 2016

Copy link
Copy Markdown
Author

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