Created
March 9, 2026 08:50
-
-
Save jakubzitny/2adb5cf70117a445720abb21b10922b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // stiahne odpovedd z BoozeAPI | |
| fetch("https://boozeapi.com/api/v1/cocktails") | |
| .then((odpoved_raw) => { | |
| odpoved_raw.json().then((odpoved) => { | |
| // dekoduje odpoved (a vypise do konzole) | |
| console.log(odpoved.data) | |
| // pre kazdy drink vyrobi <img> element a pripoji do mojDivVJs | |
| odpoved.data.forEach((drink) => { | |
| const drinkImg = document.createElement("img") | |
| drinkImg.src = drink.image | |
| drinkImg.width = 200 | |
| // pripoji ("append") ako dieta do mojDivVJs | |
| mojDivVJs.appendChild(drinkImg) | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment