17 lines
No EOL
680 B
JavaScript
17 lines
No EOL
680 B
JavaScript
const continentList = document.getElementById("continent-list");
|
|
fetch("https://countries.trevorblades.com/", {
|
|
method: "POST",
|
|
body: JSON.stringify(
|
|
{
|
|
query: "", // Fill in Query here
|
|
"operationName": "allContinents"
|
|
}),
|
|
headers: { "Content-Type": "application/json" }
|
|
}).then(response => response.json()).then(({ data }) => {
|
|
const continents = data.continents;
|
|
for (const continent of continents) {
|
|
const newListItem = document.createElement("li");
|
|
newListItem.innerHTML = `<a href="/continent.html?code=${continent.code}"> ${continent.name} </a>`;
|
|
continentList.append(newListItem);
|
|
}
|
|
}); |