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

method to intercept request to rewrite request url #603

Closed
airtonix opened this issue Mar 2, 2014 · 20 comments
Closed

method to intercept request to rewrite request url #603

airtonix opened this issue Mar 2, 2014 · 20 comments

Comments

@airtonix
Copy link
Contributor

airtonix commented Mar 2, 2014

This is a question about addRequestInterceptor.

Despite having access to the initial request URL (that is created by the URL builder), it doesn't seem to allow me to change the URL that ends up being used, I could be wrong.

My use case is this :

  • My data is stored as static JSON files on github pages.
  • I use angular
  • I'm building a resource that pulls collections or a single item based on a reference like api/recipe/453

I'd like to transform the request url on the .one(453) from api/recipe/453/data.json to merely api/recipe/data.json then pull out the item with id matching 453 using some lodash.

I feel that addRequestInterceptor meets all but one of those needs (that of rewriting the eventual url used).

Can you clarify if addRequestInterceptor makes it possible to do the following:

  • change the URL used to make the request
  • manipulate the data retrieved with something like lodash
  • use cached data instead of making http requests.
@mgonto
Copy link
Owner

mgonto commented Apr 25, 2014

Hey,

I think this makes sense.

Marking as enhancement :).

Thanks!

@Bclayson
Copy link

Was this ever done? I am in a similar position and can't figure out how to actually change the request url.

@lucval
Copy link

lucval commented Jun 17, 2015

Wondering whether this was ever done or planned to be done.. It will be very useful indeed.

@scheeles
Copy link

1+

@maxlegault
Copy link

+1

5 similar comments
@ghost
Copy link

ghost commented Jul 21, 2015

+1

@fvezzoso
Copy link

+1

@TimoSolo
Copy link

+1

@danibasauri
Copy link

+1

@abstratt
Copy link

abstratt commented Sep 8, 2015

+1

@jamespsterling
Copy link

+1, doesn't appear to work in the addFullRequestInterceptor() method

@fzaninotto
Copy link

👍

@ElielBarone
Copy link

+1

@daurnimator
Copy link

daurnimator commented Jun 1, 2016

Any progress on this?

This is causing me issues when trying to back ng-admin with postgrest. The style of workaround shown at https://github.com/marmelab/ng-admin-postgrest/blob/master/main.js#L39 doesn't work in the general case.

@daviesgeek
Copy link
Collaborator

This was done with setRequestSuffix

I'm going to close this for now; feel free to re-open if there's still an issue

@daurnimator
Copy link

setRequestSuffix isn't enough at all.
I need to change the url from /foo/bar?some=query to /foo?id=bar&some=query

(I can't reopen)

@daviesgeek
Copy link
Collaborator

@daurnimator Your issue is a separate issue than the OP. How about you open up another issue with your specific use case?

@daurnimator
Copy link

@daurnimator Your issue is a separate issue than the OP. How about you open up another issue with your specific use case?

I can; though there are many blog posts/faqs/stack overflow answers out there that already point to this issue as the relevant one for what I'm asking.

@daviesgeek
Copy link
Collaborator

@daurnimator While many other external sources may point to this issue, the OP's question was how to append .json to the end of the URL, which was solved. Your specific issue, which I think is completely valid, is how to append parameters to the url, which could also extend to modifying the URL in a more substantial way than just adding a suffix.

It looks like this is already supported (see my Plunk), but if that still doesn't answer your question, please feel free to open another issue

@allentc
Copy link

allentc commented Jun 24, 2016

@daviesgeek Respectfully, the OP's question was not about appending .json to the end of the URL. The OP provided an illustration of what was intended; changing the path part of the URL from api/recipe/453/data.json to api/recipe/data.json. The OP asked if Restangular permitted one to "change the URL used to make the request" via addRequestInterceptor, not merely the parameters. @daurnimator subsequently asked for the same capability to alter the URL in addRequestInterceptor, not merely the parameters, as in your Plunk example. I believe the issue as written by the OP and others has not been addressed and that the issue should be open.

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

No branches or pull requests