Return a simple Hello World string directly from a function running on Azion’s global network. This is the most basic example of using respondWith to send a custom response without contacting an origin server.

async function handleRequest(request) {
return new Response(" Functions JavaScript - General Availability")
}
addEventListener("fetch", event => {
return event.respondWith(handleRequest(event.request))
})

How it works

The function registers a handler for the fetch event with addEventListener. When a request arrives, handleRequest builds a new Response containing the text to return, and event.respondWith() sends that response back to the client. Because the logic runs on Azion’s distributed architecture, the response is delivered with very low latency, close to the user.

You can adapt this pattern to return any content — plain text, HTML, or JSON — by changing the value passed to Response. It’s a useful starting point for confirming that your function is deployed correctly and serving traffic from Azion’s global network before you add more complex logic.