Add basis for exercise as well as task description
This commit is contained in:
parent
c449843941
commit
41ae601c19
9 changed files with 200 additions and 1 deletions
20
js/currency.js
Normal file
20
js/currency.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const currency = new URLSearchParams(window.location.search).get("currency");
|
||||
const countryList = document.getElementById("country-list");
|
||||
fetch("https://countries.trevorblades.com/", {
|
||||
"method": "POST",
|
||||
"body": JSON.stringify(
|
||||
{
|
||||
query: "", // Fill in Query here
|
||||
"operationName": "countriesPayingIn",
|
||||
"variables": { "currency": currency }
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}).then(response => response.json()).then(({ data }) => {
|
||||
document.getElementById("currency").innerText = currency;
|
||||
const countries = data.countries;
|
||||
for (const country of countries) {
|
||||
const newListItem = document.createElement("li");
|
||||
newListItem.innerHTML = `<a href="/country.html?code=${country.code}"> ${country.name} </a>`;
|
||||
countryList.append(newListItem);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue