Fungsi async dapatkan API
async function getAllRecepies() {
let response = await fetch("receipe.json")
let data = await response.json()
return data
}
function getRecepieHtml(aRecepie){
return `
<table>
<tr>
<td class="center"><strong>Id:</strong> ${aRecepie.id}</td>
<td><strong>Menu:</strong> ${aRecepie.menu}</td>
<td><strong>Chef:</strong> ${aRecepie.chef}</td>
<td><strong>Time:</strong> ${aRecepie.time.join(' / ')}</td>
<td><strong>Ingredients:</strong> ${aRecepie.ingredients.join('<br>')}</td>
<td><img src="food.png"></td>
</table>
`
}
setTimeout(()=> {
getAllRecepies().then(allRecepies => {
document.getElementById('recepies').innerHTML =
`<div class="my-recepie-list">
${allRecepies.map(getRecepieHtml).join('')}
</div>`
})
}, 500)
Yvonne A.Okocha