Compare commits
No commits in common. "solution" and "main" have entirely different histories.
4 changed files with 11 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ fetch("https://countries.trevorblades.com/", {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"body": JSON.stringify(
|
"body": JSON.stringify(
|
||||||
{
|
{
|
||||||
query: "query continent($code: ID!) { continent(code: $code) { name countries { name code }}}",
|
query: "", // Fill in Query here
|
||||||
"operationName": "continent",
|
"operationName": "continent",
|
||||||
"variables": { "code": continentCode }
|
"variables": { "code": continentCode }
|
||||||
}), headers: { "Content-Type": "application/json" }
|
}), headers: { "Content-Type": "application/json" }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ fetch("https://countries.trevorblades.com/", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(
|
body: JSON.stringify(
|
||||||
{
|
{
|
||||||
query: "query allContinents { continents { name code }}",
|
query: "", // Fill in Query here
|
||||||
"operationName": "allContinents"
|
"operationName": "allContinents"
|
||||||
}),
|
}),
|
||||||
headers: { "Content-Type": "application/json" }
|
headers: { "Content-Type": "application/json" }
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,19 @@ fetch("https://countries.trevorblades.com/", {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"body": JSON.stringify(
|
"body": JSON.stringify(
|
||||||
{
|
{
|
||||||
query: "query country($code: ID!) { country(code: $code) { name capital phones currencies languages { name native } emoji }}",
|
query: "", // Fill in Query here
|
||||||
"operationName": "country",
|
"operationName": "country",
|
||||||
"variables": { "code": countryCode }
|
"variables": { "code": countryCode }
|
||||||
}),
|
}),
|
||||||
headers: { "Content-Type": "application/json" }
|
headers: { "Content-Type": "application/json" }
|
||||||
}).then(response => response.json()).then(({ data }) => {
|
}).then(response => response.json()).then(({ data }) => {
|
||||||
document.getElementById("country-heading").innerText = data.country.name;
|
/*
|
||||||
document.getElementById("country-capital").innerText = data.country.capital;
|
Use the information from the response to insert the following text into the page:
|
||||||
document.getElementById("flag-symbol").innerText = data.country.emoji;
|
- Name of the country
|
||||||
|
- Capital of the country
|
||||||
|
- Flag of the country as unicode emoji
|
||||||
|
*/
|
||||||
|
|
||||||
for (const language of data.country.languages) {
|
for (const language of data.country.languages) {
|
||||||
const newListItem = document.createElement("li");
|
const newListItem = document.createElement("li");
|
||||||
newListItem.innerText = language.name;
|
newListItem.innerText = language.name;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ fetch("https://countries.trevorblades.com/", {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"body": JSON.stringify(
|
"body": JSON.stringify(
|
||||||
{
|
{
|
||||||
query: "query countriesPayingIn($currency: [String!]!) {countries(filter: {currency: {in:$currency}}) { name code }}",
|
query: "", // Fill in Query here
|
||||||
"operationName": "countriesPayingIn",
|
"operationName": "countriesPayingIn",
|
||||||
"variables": { "currency": currency }
|
"variables": { "currency": currency }
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue