How do I retrieve the response time for a request like this..
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
You can store the time before the request, get the time after the request finishes, and subtract the two to get the difference:
const before = new Date();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
const now = new Date();
const diff = now - before;
console.log("Took " + diff + " milliseconds");
}
};