Hello, i am trying to make a side project using game of thrones API. Out of curiosity, I want to print all the characters name from https://www.anapioficeandfire.com/api/characters .
From the response headers and documentation (https://anapioficeandfire.com/Documentation#pagination), I see this Api has 214 pages. How do i fetch the character names from all of these 214 pages.
My Current attempt allows me to get names from only 1st 10 objects
Here is my attempt :
(function() {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(req.getResponseHeader("link"));
let charObj = JSON.parse(this.responseText);
for (let i = 0; i < charObj.length; i++) {
let p = document.createElement("p");
let name = document.createTextNode(charObj[i].name);
p.appendChild(name);
document.body.appendChild(p);
}
}
};
req.open("GET", "https://www.anapioficeandfire.com/api/characters", true);
req.send();
})();