1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export async function TanaPasteExample(req, res) {
// you call this functioin from Tana's make API request
// as https://api.val.town/express/@bikefixe.TanaPasteExample?arg=stufftopassin
// then you'd call the API where the data you want resides
// a search term might've been passed in
// const url = https://something@domain.com?searchterm=${req.query.arg}
// let response = await fetch(url);
// const theText = JSON.parse(await response.text());
// continue assuming theText had been filled with response text
// the response data object might have some fields to work with
// we'll use this dummy in its place
// dummy object
let dummy = {
name: "John Smith",
phone: "000-123-4567",
email: "foo@bar.com",
};
// then build a string in Tana Paste format.
// if you're working from a Make API request command,
// then the %%tana%% header isn't required
const outputString = `- ${dummy.name} #mysupertag
- Email:: ${dummy.email}
- Phone:: ${dummy.phone}
`;
//return the string to Tana
res.send(outputString);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023