| 119 | //promise =>pending=>setteled-- i)fulfilled-sucessful ii)rejected |
| 120 | |
| 121 | const renderCountry = function (data, className = '') { |
| 122 | const html = ` |
| 123 | <article class="country ${className}"> |
| 124 | <img class="country__img" src="${data.flag}" /> |
| 125 | <div class="country__data"> |
| 126 | <h3 class="country__name">${data.name}</h3> |
| 127 | <h4 class="country__region">${data.region}</h4> |
| 128 | <p class="country__row"><span>👫</span>${( |
| 129 | +data.population / 1000000 |
| 130 | ).toFixed(1)}M people</p> |
| 131 | <p class="country__row"><span>🗣️</span>${data.languages[0].name}</p> |
| 132 | <p class="country__row"><span>💰</span>${data.currencies[0].name}</p> |
| 133 | </div> |
| 134 | </article> |
| 135 | `; |
| 136 | countriesContainer.insertAdjacentHTML('beforeend', html); |
| 137 | countriesContainer.style.opacity = 1; |
| 138 | }; |
| 139 | /*const request = fetch(`https://restcountries.com/v2/name/nepal`); //fetch function return a promise |
| 140 | console.log(request); |
| 141 | const getCountryData = function (country) { |