method to intercept request to rewrite request url
See original GitHub issueThis 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:
- Created 10 years ago
- Reactions:4
- Comments:20 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
toapi/recipe/data.json
. The OP asked if Restangular permitted one to “change the URL used to make the request” viaaddRequestInterceptor
, not merely the parameters. @daurnimator subsequently asked for the same capability to alter the URL inaddRequestInterceptor
, 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.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.