Please explain the primary difference between ValueTypes (fairly straightforard) and ValueHintTypes. I don’t understand the definition below.
Enumeration: ValueHintType
Synthetic types that instruct Coda how to coerce values from primitives at ingestion time.
Ouch, that language is hard to read! Our reference documentation needs a lot more polish, but this page in the guides is a bit more approachable:
To indicate that Coda should display your value in a more meaningful way you can set a value hint. The enumeration ValueHintType
defines the set of supported value hints, which correspond to the column formats in Coda.
This table that shows the mapping between Coda column types and ValueType
+ ValueHintType
might also help clear it up? Let me know if you have any follow-up questions.
1 Like
Thank you Eric. That helps!
One more question related to the sunrise - sunset pack:
What does context mean in this line of code?
execute: async function ([lat, lng, date], context) {
1 Like
Context is kind of a magic thing that you can mostly ignore (but you have to include it). Basically it gives you access to things like the API authentication you’ve configured, the built-in fetching function for hitting API endpoints, etc.
For example, when reaching out to an API, you write something like:
let response = await context.fetcher.fetch({
method: "GET",
url: url,
});
You’re able to write “context.
” because you’ve included “context
” up in that execute
line.
.
That’s mostly all you need to know but to take it one step further, I often create a totally separate function to handle my executes, and I pass context
along the chain. So I have something like:
execute: async function ([lat, lng, date], context) {
return getDaylight(lat, lng, date, context);
}
and then elsewhere I define how that function works:
export async function getDaylight(lat, lng, date, context) {
let response = await context.fetcher.fetch({
method: "GET",
url: url,
});
// do complex stuff that was too big & ugly for my taste to include
// in the formula definition - in fact this is usually stuffed in some
// some other file (I use the command-line approach which allows
// for multiple files)
}
2 Likes
Oh I see Eric answered in your other thread 
1 Like
It’s a great answer though @Nick_HE ! I just realized my user settings were set such that I wasn’t getting notified of replies, whoops! Should be fixed now.
2 Likes