const getAll = () => {
let url = "https://restcountries.com/v3.1/all";
fetch(url)
.then(res => res.json())
.then(data => printData(data))
.catch(err => console.log(err))
}
const printData = (data) => {
data.forEach(country => {
const {name:{common}, region, population, capital, currencies, flags:{svg:flagImage}} = country
const countryDiv = document.querySelector("#countryDiv")
countryDiv.innerHTML += `
<img src="${flagImage}" width="300px">
<h2>Country: ${common}</h2>
<h2>Capital: ${capital}</h2>
<h2>Region: ${region}</h2>
<h2>Population: ${population}</h2>
`
})
}