I am attempting to add a single parameter to all my web requests so that caching is forcibly disabled. All I want to do is add
?v=1535DC9D930 // Current timestamp in hex
to the end of every request.
I am writing this in plain ES5 JS, but all the documentation is in Typescript which is taking a little while to convert. I have the following so far:
(function(app) {
app.CustomHttp = ng.core
.Class({
constructor: [ng.http.Http, function(http) {
console.log(this);
this.http = http;
}],
request: function() {
return this.http.request.apply(arguments);
},
get: function() {
return this.http.get.apply(arguments);
},
post: function() {
return this.http.post.apply(arguments);
},
put: function() {
return this.http.put.apply(arguments);
},
delete: function() {
return this.http.delete.apply(arguments);
},
patch: function() {
return this.http.patch.apply(arguments);
},
head: function() {
return this.http.head.apply(arguments);
}
});
})(window.app || (window.app = {}));
(function(app) {
document.addEventListener('DOMContentLoaded', function() {
ng.core.enableProdMode();
ng.platform.browser.bootstrap(
app.AppComponent,
[ng.core.provide(ng.http.Http, { useClass: app.CustomHttp })]
).catch(function(error) {
console.error(error);
});
});
})(window.app || (window.app = {}));
The app fully works, yet the console.log(this) in the CustomHttp never gets called, and when I inspect ng.http.HTTP_PROVIDERS in the browser it doesn't appear to be using CustomHttp. I have also tried:
[ng.http.HTTP_PROVIDERS, ng.core.provide(ng.http.Http, { useClass: app.CustomHttp })]
In my boot.js to no avail.
I'm sure there is something tiny that I am missing, or that I have massively over complicated this (How hard can it be to add a single parameter to all get requests?).