I cannot seem to get the categories(planets,dwarfplanets and other) inside the dropdown menu. I know I should use data.something but idk what, any help?
HTML
<select id="categories"></select>
The link to my json api
[https://howest-gp-wfa.github.io/st-2021-1-S2-ee-solar-system-Jonas-Bundervoet/api/data.json][1]
For my javascript I have this
"use strict"
window.addEventListener("load", Init);
var categories;
function Init()
{
categories = document.getElementById("categories");
FetchData();
}
function FetchData(){
fetch("https://howest-gp-wfa.github.io/st-2021-1-S2-ee-solar-system-Jonas-Bundervoet/api/data.json")
.then(
function(response) {
if (response.status !== 200) {
console.warn('Looks like there was a problem. Status Code: ' +
response.status);
return;
}
response.json().then(function(data) {
let option;
for (let i = 0; i < data.length; i++) {
option = document.createElement('option');
option.text = data[i].name;
categories.add(option);
}
});
}
)
.catch(function(err) {
console.error('Fetch Error -', err);
});
}