Being new to javascript, I am uncertain about how to properly add JSON data to an array. I am using the fetch command to retrieve the JSON file. Below is the code snippet for fetching the JSON file:
fetch("event.json")
.then(response => response.json())
.then(json => console.log(json));
I am now facing the challenge of adding this fetched data to an array. Any assistance on this matter would be highly appreciated!
Below is the JSON that I am currently retrieving:
{
"id": "1",
"name": "Tim",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1f5c8cce1c6ccc0c8cd8fc2cecc">[email protected]</a>",
"event":[{"id":1,"name":"HomeShow"}]
}
The JSON file contains information on multiple individuals. My goal is to fetch this file, store it in an array, and then iterate through it to extract specific values.