Hi I’m learning javascript.
And I’m trying to iterate thru a json file with js fetch.
I am first retrieving the whole file which I would then use to go through the list and get
randomly every nth result from a random object.
UPDATE:
I’ve managed to console log an element of the json list.
I’m still searching a good way to push the element to a div
And
When onload of the body a new element is presented.
Current code:
var myfetch = fetch("https://kanjialive-api.p.rapidapi.com/api/public/kanji/all", {
"method": "GET",
"headers": {
"x-rapidapi-host": "kanjialive-api.p.rapidapi.com",
"x-rapidapi-key": "x"
}
})
myfetch
.then((res) => res.json())
.then((data) => console.log(data[1].kanji.character))
.then((data) =>
document.getElementById('kanji').innerHTML = kanji.character)
.catch(err => {
console.log(err);
});
I get undefined in my html now!