@seapagan
Posted
Using fetch to get a local JSON file is not so complicated; just remember it returns a promise, so you should await
it and then convert it back to JSON. For the provided file it can be done in one line :
const data = await fetch("data.json").then((res) => res.json());
Then just iterate over the data object using a forEach
or similar. You may need to specify a path for the JSON file depending on where you put it in relation to your component.
Marked as helpful
@CreatorLZ
Posted
@seapagan Thanks man. I'm using this in whatever I'll build next
@seapagan
Posted
@CreatorLZ you're very welcome 😀