Hello all from the coding Newbie!
I am attempting to fetch the data from the free travelbriefing.org API. The return JSON data is as follows:
“names”: {
"name": "Netherlands",
"full": "Kingdom of the Netherlands",
"iso2": "NL",
"iso3": "NLD",
"continent": "EU"
},
"maps": {
"lat": "52.2129919",
"long": "5.2793703",
"zoom": "7"
},
"timezone": {
"name": "Europe/Amsterdam"
},
"language": [
{
"language": "Dutch",
"official": "Yes"
}
],
"electricity": {
"voltage": "230",
"frequency": "50",
"plugs": [
"C",
"F"
]
},
"telephone": {
"calling_code": "31",
"police": "112",
"ambulance": "112",
"fire": "112"
},
"water": {
"short": "safe",
"full": ""
},
"vaccinations": [],
"currency": {
"name": "Euro",
"code": "EUR",
"symbol": "€",
"rate": "0.92284",
'********************************************************************
I used the following Code to Execute and retrieve the data:
execute: async function (, context) {
const url = "https://travelbriefing.org/Netherlands?format=json";
// context.fetcher.fetch allows you to pull in external data, specifying things like the HTTP method and URL.
const response = await context.fetcher.fetch({ method: 'GET', url });
// The entire body of the response contains the ltext to be returned.
return response.body
},
// In this formula, we're returning a string.
resultType: coda.ValueType.String,
});
'****************************************
I can build the pack, and add it to a doc, but only the name “Netherlands” appears and I must hover over the word to see the data.
Is there a way to break out the data either in the Pack code or on the CODA canvas? The “.” operator is not working on the Coda canvas.
Also, is there a way to add a parameter so that the user can input different countries besides hardcoding it in the URL? The API does not specify parameters, unlike the Sunrise-Sunset pack. Would it be best to build a sync table in this situation to pull in the data?
Thank you in advance.