Read more about XMLHttpRequest.open(): HERE
Here is the solution HTML + the script:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<button onclick="loadRepos()">Load</button>
<div id="res"></div>
<script>
function loadRepos() {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("res").textContent =
this.responseText;
}
};
req.open("GET",
"https://api.github.com/users/testnakov/repos", true);
req.send();
}
</script>
</body>
</html>
Only the script:
function loadRepos() {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("res").textContent =
this.responseText;
}
};
req.open("GET",
"https://api.github.com/users/testnakov/repos", true);
req.send();
}