How to write data into variable with XMLHttpRequest?

Hello, need help with obtaining and recording data into a variable
How do I query the data and write into a variable?

Request Url: https://uinames.com/api/?gender=female®ion=russia
XMLHttpRequest();

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://uinames.com/api/?gender=female&region=russia");
xhr.send();
xhr.onreadystatechange = function() {
 if (this.readyState == 4 && this.status == 200) {
 const data = JSON.parse(this.responseText);
}
}
April 7th 20 at 10:48
1 answer
April 7th 20 at 10:50
Solution

Find more questions by tags JavaScript