question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

method to intercept request to rewrite request url

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:4
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
allentccommented, Jul 5, 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.

1reaction
daurnimatorcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intercept HTTP requests - Mozilla - MDN Web Docs
To intercept HTTP requests, use the webRequest API. ... The logURL() function grabs the URL of the request from the event object and...
Read more >
How to intercept a request by URL base? - Stack Overflow
You can obtain the request URI by HttpServletRequest#getRequestURI() in filter's doFilter() method as follows:
Read more >
Modify URL Request with the Breakpoint Tool - Proxyman
This mini-tutorial would demonstrate how to modify the URL Request (HTTP Method, Scheme, Host, Port, Path, and Query) with the Breakpoint Tool.
Read more >
Requestly - Lightweight Proxy to Intercept & Modify HTTP(s ...
Requestly lets developers Modify Headers, Redirect URLs, Switch Hosts, Mock API Response, Delay Network requests, and much more. Download for Chrome. Chrome.
Read more >
Back to Basics: Rewriting a URL in ASP.NET Core - Rick Strahl
If you plan to intercept requests and rewrite them , the most likely place you'd want to do this is in ASP.NET Core...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found