Everything you need to know to build powerful functions.
Your function receives a `request` object containing all the details of the incoming HTTP request. It has the following structure:
{
"method": "GET",
"headers": { ... },
"url": "http://...",
"path": "/sub/path",
"query": { "param": "value" },
"json": { "key": "value" },
"form": { "field": "value" },
"text": "plain text body"
}
The `environment` object is a mutable JSON object that persists across function executions. You can read from it and write to it to maintain state.
// Example: A simple counter
async (req) => {
if (!environment.counter) {
environment.counter = 0;
}
environment.counter++;
return JsonResponse({ count: environment.counter });
}
Several helper functions are available globally to make creating responses easier:
You can use `console.log()` and `console.error()` within your function. The output will be captured and displayed in the function's logs, which you can view in your dashboard.