-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
29 lines (26 loc) · 759 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// get the countries from API
// print these countries
// create a element for each country
// add that element to the select drop down
document.addEventListener('DOMContentLoaded', ()=>{
const selectElem = document.querySelector('select#countries')
fetch('https://54.72.28.201:80/1.0/countries', {
headers: {
accept: 'application/json; charset=utf=8'
}
})
.then((res)=>{
return res.json()
})
.then((json)=>{
printCountries(json.countries)
})
function printCountries(list){
console.log(list)
list.forEach((item)=>{
const elem = document.createElement('option')
elem.textContent = item;
selectElem.appendChild(elem)
})
}
})