├── css └── countries.css ├── js ├── kanye.js ├── buddy.js ├── countries.js ├── mealdb.js └── mealdbasync.js ├── buddy.html ├── kanye.html ├── countries.html └── mealdb.html /css/countries.css: -------------------------------------------------------------------------------- 1 | #countries{ 2 | display: grid; 3 | grid-template-columns: repeat(3, 1fr); 4 | } 5 | .country{ 6 | border: 2px solid tomato; 7 | margin: 10px; 8 | padding: 20px; 9 | border-radius: 10px; 10 | } -------------------------------------------------------------------------------- /js/kanye.js: -------------------------------------------------------------------------------- 1 | const loadQuotes = () => { 2 | fetch('https://api.kanye.rest/') 3 | .then(res => res.json()) 4 | .then(data => displayQuote(data)); 5 | } 6 | 7 | const displayQuote = quote => { 8 | const quoteElement = document.getElementById('quote'); 9 | quoteElement.innerText = quote.quote; 10 | } -------------------------------------------------------------------------------- /buddy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |15 |16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /js/buddy.js: -------------------------------------------------------------------------------- 1 | const loadBuddies = () => { 2 | fetch('https://randomuser.me/api/?results=5') 3 | .then(res => res.json()) 4 | .then(data => displayBuddies(data)); 5 | } 6 | loadBuddies(); 7 | 8 | const displayBuddies = data => { 9 | console.log(data); 10 | const buddies = data.results; 11 | const buddiesDiv = document.getElementById('buddies'); 12 | for (const buddy of buddies) { 13 | const p = document.createElement('p'); 14 | p.innerText = `Name: ${buddy.name.title} ${buddy.name.first} ${buddy.name.last} email: ${buddy.email}`; 15 | buddiesDiv.appendChild(p); 16 | } 17 | } -------------------------------------------------------------------------------- /countries.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
${country.capital}
20 | 21 | `; 22 | countriesDiv.appendChild(div); 23 | }); 24 | } 25 | 26 | const loadCountryByName = name => { 27 | const url = `https://restcountries.eu/rest/v2/name/${name}`; 28 | fetch(url) 29 | .then(res => res.json()) 30 | .then(data => displayCountryDetail(data[0])); 31 | } 32 | 33 | const displayCountryDetail = country => { 34 | console.log(country); 35 | const countryDiv = document.getElementById('country-detail'); 36 | countryDiv.innerHTML = ` 37 |population: ${country.population}
39 |Something went wrong please try again later
24 |${meal.strInstructions.slice(0, 200)}
41 |${meal.strInstructions.slice(0, 200)}
45 |