Hello world
Return a fixed string from a function, without contacting an origin, and confirm the function is deployed and serving traffic.
Return a fixed string directly from a function, without contacting an origin server. This is the smallest form of the pattern every function follows, which makes it a useful check that a function is deployed and serving traffic before you add logic to it.
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 code runs on Azion’s distributed infrastructure, the response is delivered close to the user, with no request to an origin.
The same pattern returns any kind of content. Change the value passed to Response for a different body, and set a content-type header when the body is HTML or JSON.