-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
1 lines (1 loc) · 942 Bytes
/
bundle.js
File metadata and controls
1 lines (1 loc) · 942 Bytes
1
const t=document.getElementById("get-recipe-btn"),n=document.getElementById("drink"),e=document.getElementById("instructions"),r=document.getElementById("ingredients"),i=document.getElementById("drinkThumb");t.addEventListener("click",(async function(t){n.textContent=e.textContent="Loading...";const s=function(t){const n=t.elements.drinks,{strDrink:e,strInstructions:r,strDrinkThumb:i,strIngredient1:s,strIngredient2:d,strIngredient3:o,strIngredient4:c,strIngredient5:g,strIngredient6:m,strIngredient7:u,strIngredient8:l}=n[0],I=[s,d,o,c,g,m,u,l];let a="";for(let t=0;t<8;t++)null!=I[t]&&(a+=I[t]+", ");return a=a.slice(0,-2),{drinkName:e,ingredients:a,instructions:r,drinkPhoto:i}}(await async function(){return{elements:await fetch("https://www.thecocktaildb.com/api/json/v1/1/random.php").then((t=>t.json()))}}());!function(t){r.textContent=t.ingredients,n.textContent=t.drinkName,e.textContent=t.instructions,i.src=t.drinkPhoto}(s)}));