Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$httpProvider request interceptor - get parameters

Tags:

angularjs

I need to add a query string to some of my $http calls. Now $httpProvider.defaults.transformRequest seems to receive 2 objects: data and a headersGetter, neither allow me to directly change the url or add a get variable.

Any ideas?

like image 266
Guy Nesher Avatar asked Feb 17 '26 05:02

Guy Nesher


1 Answers

You need an interceptor. From the angular docs on $http:

There are two kinds of interceptors (and two kinds of rejection interceptors):

request: interceptors get called with http config object. The function is free to modify the config or create a new one. The function needs to return the config directly or as a promise.

like image 119
aet Avatar answered Feb 19 '26 19:02

aet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!