I am trying to use the below code to intercept some AJAX calls from my app (which uses both axios and fetch).
(function(send) {
XMLHttpRequest.prototype.send = function(data) {
this.setRequestHeader('someHeader', 'ABC');
send.call(this, data);
};
})(XMLHttpRequest.prototype.send);
However, each execution of this line setRequestHeader seems to be appending the values and setting in the header.
E.g. if I have 3 AJAX calls on my page, for the 3rd request, I see "user" header value as "ABC ABC ABC"
Not sure if the above way is correct ?