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: "query countriesPayingIn($currency: [String!]!) {countries(filter: {currency: {in:$currency}}) { name code }}", "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 = ` ${country.name} `; countryList.append(newListItem); } });