'Get Post Data Payload From Sent XHR
I am writing some code to intercept and log ever XHR request sent over JavaScript, but I am unable to find where to access the request payload from. Is this possible to do? My code is below, this logs the url, method, and response, but no payload.
let oldXHROpen = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function (
method,
url,
async,
user,
password
) {
console.log("---hooked request---");
console.log({ url });
console.log({ method });
console.log(this);
this.addEventListener("load", function () {
console.log("load: " + this.responseText);
});
return oldXHROpen.apply(this, arguments);
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
