Gallery
Pack Building Roadmap - Maker Stories Webinar
Share
Explore
Pack Details & Code

icon picker
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"
},*/

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.