JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
The "Hot" Dog Pack
Dog Pack Instructions
Display Inspirational Messages
Display a Random Image
Data Tables
Pack Code
More
Share
Explore
Pack Code
import
*
as
coda
from
"@codahq/packs-sdk"
;
export
const
pack = coda.newPack();
pack.addNetworkDomain(
"dog.ceo"
);
pack.addColumnFormat({
name:
"Dog Column"
,
instructions:
"Use this column format to enter a dog breed name into the column and retrieve a random dog image."
,
formulaName:
"DogImage"
,
});
pack.addFormula({
name:
"DogImage"
,
description:
"Use this formula to enter a dog breed name and retrieve a random dog image. The breed options are displayed in an autocomplete list"
,
parameters: [
coda.makeParameter({
type
: coda.
ParameterType
.
String
,
name:
"Breed"
,
description:
"Dog Breed."
,
autocomplete:[
"poodle"
,
"airedale"
,
"australian"
,
"beagle"
,
"greyhound"
,
"weimaraner"
,
"wolfhound"
,
"havanese"
,
"boxer"
,
"cattledog"
,
"germanshepherd"
,
"stbernard"
,
"chihuahua"
,
"collie"
,
"cockapoo"
,
"dalmatian"
,
"labradoodle"
,
"shihtzu"
,
"havanese"
,
"hound"
,
"terrier"
,
"waterdog"
,
"papillon"
,
"corgi"
,
"collie"
,
"cockapoo"
,
"sheepdog"
,
"shihtzu"
,
"retriever"
,
"schnauzer"
,
"bulldog"
,
"retriever"
,
"setter"
,
"weimaraner"
,
"whippet"
,
"wolfhound"
,
"dachshund"
,
"sheepdog"
,
"husky"
,
"spaniel"
],
optional:
true
,
}),
],
resultType: coda.
ValueType
.
String
,
codaType: coda.
ValueHintType
.
ImageReference
,
execute:
async
function
([
Breed
], context){
if
(
Breed
==
null
)
{
let
url =
"https://dog.ceo/api/breeds/image/random"
;
let
response =
await
context.fetcher.fetch({ method:
'GET'
, url });
return
response.body.message;
}
let
url =
"https://dog.ceo/api/breed/"
+
Breed
.toLocaleLowerCase() +
"/images/random"
;
let
response =
await
context.fetcher.fetch({ method:
'GET'
, url });
return
response.body.message;
},
});
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.