auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const fetch = require('node-fetch');
const key = process.env.FAKE_CAT_API;
let resp = await fetch(`https://raymondcamden.com/.netlify/functions/get-cats?key=${key}`);
let data = await resp.json();
data = data.map(c => {
return { name: c.name, age: c.age };
});
if(steps.trigger.event.query.name) {
data = data.filter(c => c.name.toLowerCase().indexOf(steps.trigger.event.query.name) >= 0);
}
await $respond({
status:200,
body: data
})