Skip to content
Advertisement

My json api fetch seems not to work, what should I use with data?

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

JavaScript

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

JavaScript

Advertisement

Answer

You are pretty close. To get all the different types out of your data object you could use Object.keys then replace data in your loop with data[type].

Instead of add you need to use appendChild to add elements into another DOM node.

JavaScript
JavaScript

EDIT: Categories instead of planet names

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement