2. Function Stack

The Function Stack is the internal workings of the API.

The Function Stack is a "stack" of Functions that get executed in a linear fashion. They determine how an endpoint gets processed. The Function Stack is where you will build your business logic. You can add a variety of functions and get as complex as needed. You can watch the Functions video where we touch upon them.

There are a series of functions you have access to broken up into these categories:

The Inputs section should have given you a good understanding of how inputs are passed into the function stack, now let's talk about how data is passed from function to function.

How does data get passed through the function stack?

Each function stack item typically returns a Variable that you can they reference in subsequent functions in the function stack.

How do I add a function to the Function Stack?

To add a new function to the Function Stack, click on the "+" button in the top right-hand corner of the Function Stack or below an existing step in the stack.

After hitting the "+" button the window below opens up. There are a variety of options to choose from. Within each option, there are a variety of Functions you can add depending on what business logic you'd like to introduce.

Adding logic or conditions to specific Functions

Sometimes you need to specify rules when using functions like Conditionals or Preconditions or when you filter the type of records you want in a Query All Records function. Xano has a flexible Expression Builder that you'll be using to do this.

Moving or re-ordering functions

You can move or re-order function easily by clicking the drag handler to the left of the function

Copying & Pasting Functions

You can copy and paste functions in the same or other function stacks as necessary.

  • Hold shift on your keyboard and select the function(s) you wish to copy.

  • Press 🪟Ctrl + C or 🍎Cmd + C to copy, and Ctrl / Cmd + V to paste

How do I comment out (hide) a Function in the Function Stack?

Commenting out a Function can be a handy feature to utilize, especially when building complex business logic in the Function Stack. Commenting out the Function means that the Function will essentially be hidden and ignored when running the Stack. This is more advantageous than deleting the Function because the Function is saved and you don't have to start over from scratch.

To hide or comment out a Function, hover over it. Once it's hovered over, an icon of eye will appear. Click on that icon to comment out the Function. The icon will update to be slashed through and the Function will be shaded dark, indicating that it will not be executed.

Multi-Select

You can hold Shift and drag to select multiple functions in your function stack to group, disable, or delete multiple functions at once.

Last updated