- Welcome to Azion Docs
- Edge Application
- Edge Functions
- Edge Functions - JavaScript Examples
- JavaScript Examples - Using Args
Using Args
Check below how call an argument:
The first example (Code tab) depicts how you can enable the use of args by using event.args.<ARG_CREATED>
. The second example (Args tab) represents the use of JSON parameters by internal code functions.
Code tab
async function handleRequest(request, v) {
return new Response(v, {
headers: new Headers([
["X-Custom-Header", "something defined on JS"],
]),
status: 200,
});
}
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request, event.args.value));
});
Args tab
{
"value": "hello_world"
}
Didn’t find what you were looking for? Open a support ticket.