1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20


Azion Preview Deployment

Azion Preview Deployment makes it possible for you to preview the behavior of your edge functions before they go to production. New possibilities are unlocked when using the Preview, such as:

  • Test different flows based on the http method provided.
  • See the outcome of an HTML page.
  • Return data in JSON.

How does Azion Preview Deployment work?

Azion Preview Deployment depends on an auxiliar function inside your source code. This function is called PreviewProvider, and it’s responsible for debugging and simulating a request, returning the outcome to be rendered. The PreviewProvider function is represented as:

    function PreviewProvider<PreviewProvider>(args) {
        var request = new Request("https://azion.com/example", {
            method: "GET",
            headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer my-token"
            redirect: "follow",
        return handleRequest(request);

Note: without the PreviewProvider function, it isn’t possible to visualize the preview.

Now, with your simulated request running, you’re able to set different behaviors to your function, based on all properties available inside the request variable, such as:

    async function handleRequest(request){
        switch (request.Method){
            case 'GET':
             return new Response(html,{

In this code snippet, it’s defined that if a GET request is called, it returns the HTML var, containing the html to be output, and set its content type as required to perform this action.

API Builder

It’s also possible to build APIs and have the outcome based on the request method. For example:

  • You can have an object in JSON as response, if the request is a POST, by altering the content-type header and returning the object using the JSON.stringify() function.

  • In case the request is a GET, and you wish to return an HTML page, the content-type should be set as text/html:charset=UTF-8. The response is going to be presented already rendered on the preview.


    async function handleRequest(request){
        switch (request.Method){
            case 'POST':
             return new Response(objectList,{
            case 'GET':
             return new Response(html,{

The output is shown right next to the code editor. It’s possible to open it on a different tab as well, clicking on the open button.

Preview Provider and ChatGPT

The ChatGPT integration helps you to boost your productivity and, alongside the Preview Deployment, enables more analytical implementations, making it possible to test and see new ideas on the fly. Take a look at Edge Functions Chat GPT integration.


Here’s a real-life implementation of the Edge Functions ChatGPT integration:

Implementation Description
How to build an API with Edge Functions and ChatGPT See how to build an API and have its responses returned in JSON, with the help of ChatGPT

Didn’t find what you were looking for? Open a support ticket.