This is my first time attempting to fetch a local JSON file.
I've gotten the data into an array called "drinks" when I console log the array I can see all of the data from the JSON file, but when I try to use a higher order function it'll return an empty array. I'm doing this on my local live server, but I've also tried with the web server for chrome, I haven't noticed a difference.
let drinks=[];
fetch('./coldMenu.JSON', {
headers : {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
.then(response=>response.json())
.then(data=>drinks.push(...data.drinks))
console.log(drinks)
let coldMenuHtml= drinks.map(drink=>{
` <img src="${drink.img}" alt="${drink.drink}" class="im">`
});
console.log(coldMenuHtml)
The goal is to get the information from the JSON and use it to create a coffee menu. Before the menu is displayed there will be a box asking if they want to see the menu for hot or cold beverages, then I planned to fetch and put the information onto the page.