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

Comments

Projects
None yet
@airtonix
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

This comment has been minimized.

Show comment
Hide comment
@mgonto

mgonto Apr 25, 2014

Owner

Hey,

I think this makes sense.

Marking as enhancement :).

Thanks!

Owner

mgonto commented Apr 25, 2014

Hey,

I think this makes sense.

Marking as enhancement :).

Thanks!

@mgonto mgonto added the enhancement label Apr 25, 2014

@Bclayson

This comment has been minimized.

Show comment
Hide comment
@Bclayson

Bclayson Jan 15, 2015

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

Bclayson commented Jan 15, 2015

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

@lucval

This comment has been minimized.

Show comment
Hide comment
@lucval

lucval Jun 17, 2015

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

lucval commented Jun 17, 2015

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

@scheeles

This comment has been minimized.

Show comment
Hide comment
@scheeles

scheeles commented Jun 28, 2015

1+

@bernyfox

This comment has been minimized.

Show comment
Hide comment
@bernyfox

bernyfox commented Jul 8, 2015

+1

@laicosly

This comment has been minimized.

Show comment
Hide comment
@laicosly

laicosly commented Jul 21, 2015

+1

@fvezzoso

This comment has been minimized.

Show comment
Hide comment
@fvezzoso

fvezzoso commented Aug 15, 2015

+1

@TimoSolo

This comment has been minimized.

Show comment
Hide comment
@TimoSolo

TimoSolo commented Aug 21, 2015

+1

@danibasauri

This comment has been minimized.

Show comment
Hide comment
@danibasauri

danibasauri commented Aug 27, 2015

+1

@abstratt

This comment has been minimized.

Show comment
Hide comment
@abstratt

abstratt commented Sep 8, 2015

+1

@jamespsterling

This comment has been minimized.

Show comment
Hide comment
@jamespsterling

jamespsterling Sep 23, 2015

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

jamespsterling commented Sep 23, 2015

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

@fzaninotto

This comment has been minimized.

Show comment
Hide comment
@fzaninotto

fzaninotto commented Sep 30, 2015

👍

@ElielBarone

This comment has been minimized.

Show comment
Hide comment
@ElielBarone

ElielBarone commented Feb 26, 2016

+1

@daurnimator

This comment has been minimized.

Show comment
Hide comment
@daurnimator

daurnimator 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.

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

This comment has been minimized.

Show comment
Hide comment
@daviesgeek

daviesgeek Jun 16, 2016

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

Collaborator

daviesgeek commented Jun 16, 2016

This was done with setRequestSuffix

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

@daviesgeek daviesgeek closed this Jun 16, 2016

@daurnimator

This comment has been minimized.

Show comment
Hide comment
@daurnimator

daurnimator Jun 17, 2016

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)

daurnimator commented Jun 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@daviesgeek

daviesgeek Jun 17, 2016

Collaborator

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

Collaborator

daviesgeek commented Jun 17, 2016

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

@daurnimator

This comment has been minimized.

Show comment
Hide comment
@daurnimator

daurnimator Jun 18, 2016

@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.

daurnimator commented Jun 18, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@daviesgeek

daviesgeek Jun 18, 2016

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

Collaborator

daviesgeek commented Jun 18, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@allentc

allentc 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.

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