How to send a query parameter to a (server side data) server action and use the output through EJS

It took some time to understand server side data, I figured I’d share my documentation to help others :slight_smile:

In this example I’m loading the server action on a content page. I want 2 things:

Step 1. Create a content page and catch the query parameter, for me it’s :checkout_id

Step 2. Create a server connect, for me it’s called Checkout_get_stripe_acc
Step 3. In the server connect we want to use the the query parameter from step 1, we can do that by defining $_PARAM.checkout_id

Step 4. The output of the server connect can be anything you want. In my example I made a Set Value with the name sc_output and value ‘checkout $_PARAM here:’+$_PARAM.checkout_id

Step 5. On your layout or content page, load your server connect under app → Server side data :

Step 6. In your routes.json file add the following code: “data”: {“ejsVar”: “{{sc_output}}”} it should look like this:

Step 7. Last step, to display on the page try one of these 2 methods (not sure when to use which one):

image.png

Step 8. For each method replace ejsVarKey with the key here

Tips:

To easily get the right variable name from your server connect:


2.

Full example of using the input in the database query and using the result on page:

  1. In server action:

  1. In routes.json

  2. On the page:

Community Page
Last updated: