JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Pack Building Roadmap - Maker Stories Webinar
Share
Explore
Gallery
Pack Building Roadmap - Maker Stories Webinar
Pack Building Roadmap - Maker Stories Webinar
Webinar Outline
Roadmap
Travel Brief App
App Highlights
Pack Makers' Checklist
Pack Builder Interface
Pack Types
Pack Details & Code
TBCountries Code
TravelBriefData Code
Pack Data & Formulas
API Data
My Pack Formulas
Daylight | Weather Formulas
Wikipedia Pack
Data Tables
Getting Started with Packs
Build your Pack
Improve your Pack
Hello Fetcher Sample Code
Questions | Feedback
All Comments
Notes
Pack Details & Code
TBCountries Code
//Starter code for all packs
import
*
as
coda
from
"@codahq/packs-sdk"
;
export
const
pack = coda.newPack();
//Identify API domain name
pack.addNetworkDomain(
"travelbriefing.org"
);
//Add a Formula
pack.addFormula({
name:
"TBCountries"
,
description:
"Return all countries from the travelbrief website."
,
parameters: [
],
//Return country names and urls in response.body
resultType: coda.
ValueType
.
String
,
execute:
async
function
([], context) {
let
url =
"https://travelbriefing.org/countries.json"
;
let
response =
await
context.fetcher.fetch({ method:
'GET'
, url });
return
response.body;
}
});
/* Postman Responses to API Get call: Example List of Countries
https://travelbriefing.org/countries.json
{
"name": "Afghanistan",
"url": "https://travelbriefing.org/Afghanistan?format=json"
},
{
"name": "Aland Islands",
"url": "https://travelbriefing.org/Aland_Islands?format=json"
},
{
"name": "Albania",
"url": "https://travelbriefing.org/Albania?format=json"
},*/
Gallery
Share
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.