Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

In our application, with every request, the front end hashes the url + the data and sends them to the server. The server then verifies that the query parameters as well as the data have not been tampered. However, in the httpinterceptor, I can only view config.url and config.params. There is no way to get the absolute url, so I can't hash against it directly. How would I go about doing this? I tried something along the lines of

var url;
var params;
for (var i = 0; i < config.params.length; i++){
    params+=config.params[i].name+'='+config.params[i].value;
}
url = config.url+'?'+params;

However this doesn't work because I can't seem to access the params this way. Also, how can I be sure that the params are in the same order as the request url? Obviously if it's even 1 character different, the hash won't be right.

share|improve this question
    
Why not window.location.href ? – Avraam Mavridis Oct 26 '15 at 16:14
    
why is it so hard to get absolute url? You know what the base is in your app and could easily set it as a constant – charlietfl Oct 26 '15 at 16:33
    
@charlietfl Getting the base url is fine with config.url, but I need the query string as well. – Alex Kibler Oct 26 '15 at 16:50
    
@AvraamMavridis, window.location.href only helps with the url of the page I'm on. It can't help me get the URL of API calls – Alex Kibler Oct 26 '15 at 16:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.