🕸️
[BA] Web Programming
  • Introductie
  • Cursus
    • TypeScript
      • Waarom TypeScript?
      • Nieuw project
      • Wat is een tsconfig.json?
      • Input lezen
      • Type Systeem
        • Basic types
        • Arrays
        • Functions
        • Class
        • Interface
      • Conditionele blok
      • Loops
      • Array methods
      • Exceptions
      • Modules
      • Asynchroon Programmeren
        • Promises
        • Async/Await
        • Fetch
        • JSON
    • Frontend
      • DOM Manipulatie
      • VITE
      • Deployment met Surge
    • Backend
      • Express.js
        • Basis
        • Nodemon
        • Statische Bestanden
        • Request
        • Response
        • Router
      • MySQL
    • Fullstack
      • Van Form tot Database
      • CORS
  • Labos
    • 1. TS: Basis
      • Hello Name
      • BMI Calculator
      • Interest Calculator
      • Uren en Minuten
      • Wisselgeld
      • Name from Email
      • Text Box
    • 2. TS: Arrays & functions
      • Som van getallen
      • Math Fun
      • Array Sum
      • Puntenboek
      • Rot13
      • Pokemon Team
      • Todo List String
      • Tick Tac Toe
      • BMI Calculator Multi
    • 3. TS: Interfaces & classes
      • Recepten
      • Transportmiddelen
      • Movies
      • Filter Numbers
    • 4. TS: Async & fetch
      • Promise All
      • Slow Sum
      • Cocktails Promise All
      • Joke API
      • School API
      • Cocktails API
      • Unix Timestamp API
    • 5. TS: Modules & NPM
      • Math Module
      • Cowsay Module
      • Cat GPT
      • Rainbow Chalk
    • 6. Frontend: VITE & DOM
      • Verander achtergrond
      • Verander tekst
      • Verander divs
      • Verander kleuren
      • Verander kleuren random
    • 7. Frontend: APIs & DOM
      • Cocktail API met Vite
      • Weather API
      • Uitvinders
      • Rick and Morty
    • 8. Backend: Express & Requests
      • Hello Express
      • DadJoke Express
      • Reiskosten server
    • 9. Backend: MySQL & Routing
      • Reiskosten server
      • Taken server
      • Taken server met prioriteit
    • 10. Fullstack: Forms & Express & MySQL
      • Reiskosten app
      • Taken app
      • Pokémon app
Powered by GitBook

AP

On this page
  1. Labos
  2. 7. Frontend: APIs & DOM

Cocktail API met Vite

In labo 4 zijn we al aan de slag gegaan met de cocktails api.

https://www.thecocktaildb.com/api/json/v1/1/search.php?s=kiwi

Zorg er nu voor dat je de informatie van deze API op het scherm krijgt.

Eén JSON object in de resultaats array ziet er als volgt uit:

{"idDrink":"14752",
"strDrink":"Kiwi Lemon",
"strDrinkAlternate":null,
"strTags":null,
"strVideo":null,
"strCategory":"Ordinary Drink",
"strIBA":null,
"strAlcoholic":"Alcoholic",
"strGlass":"Highball glass",
"strInstructions":"Mix in highball glass. Stirr. Garnish with slice of kiwi.",
"strInstructionsES":"Mezclar en un vaso highball. Remover. Decorar con una rodaja de kiwi.",
"strInstructionsDE":"Im Highball-Glas untermischen. R\u00fchren. Mit einer Scheibe Kiwi garnieren.",
"strInstructionsFR":"M\u00e9langer dans un verre de type highball. Remuer. Garnir d'une tranche de kiwi.",
"strInstructionsIT":"Mescolare in un bicchiere highball.\r\nAgitare.\r\nGuarnire con una fetta di kiwi.",
"strInstructionsZH-HANS":null,
"strInstructionsZH-HANT":null,
"strDrinkThumb":"https:\/\/www.thecocktaildb.com\/images\/media\/drink\/tpupvr1478251697.jpg",
"strIngredient1":"Kiwi liqueur",
"strIngredient2":"Bitter lemon",
"strIngredient3":"Ice",
"strIngredient4":null,
"strIngredient5":null,
"strIngredient6":null,
"strIngredient7":null,
"strIngredient8":null,
"strIngredient9":null,
"strIngredient10":null,
"strIngredient11":null,
"strIngredient12":null,
"strIngredient13":null,
"strIngredient14":null,
"strIngredient15":null,
"strMeasure1":"1 part ",
"strMeasure2":"2 parts ",
"strMeasure3":"cubes",
"strMeasure4":null,
"strMeasure5":null,
"strMeasure6":null,
"strMeasure7":null,
"strMeasure8":null,
"strMeasure9":null,
"strMeasure10":null,
"strMeasure11":null,
"strMeasure12":null,
"strMeasure13":null,
"strMeasure14":null,
"strMeasure15":null,
"strImageSource":null,
"strImageAttribution":null,
"strCreativeCommonsConfirmed":"No",
"dateModified":"2016-11-04 09:28:17"}

Toon op je scherm minstens de naam (strDrink), instructies (strInstructions) en foto (strDrinkThumb). Meer attributen tonen mag uiteraard.

Om andere ingrediënten te gebruiken ipv 'kiwi' kan je proberen om een invulveld te voorzien, maar het is ook al goed om met enkele knoppen te werken : 'kiwi cocktails' , 'lemon cocktails', 'banana cocktails' ...

Previous7. Frontend: APIs & DOMNextWeather API

Last updated 5 months ago

Probeer als visuele representatie 'cards' te maken :

https://www.w3schools.com/howto/howto_css_cards.asp