Custom Functions
Build business logic once and reuse it in multiple places
Last updated
Was this helpful?
Build business logic once and reuse it in multiple places
Last updated
Was this helpful?
Custom functions can be thought of as a building block for the rest of your backend. You can build a custom function just like an API endpoint, and insert that custom function into other function stacks, giving you easily reusable logic while only having to maintain it in one place. When you make a change inside of a custom function, that change is automatically in effect everywhere you have chosen to use the custom function.
Give your custom function a name, description, tags, and choose your Request History settings.
You can also choose to store your custom functions inside of a folder. If the folder already exists, just start typing the name and select it from the auto-complete. If the folder doesn't exist, you can create a new one from here.
When you're done, click Save .
When you're ready to use your new custom function in other function stacks, click , choose Custom Functions from the panel that opens, and select your custom function.
You'll be able to supply data for any inputs the custom function is expecting here.
If you have a function stack that you'd like to convert into a custom function, you can do so in one of the following ways.
Name
The name of the custom function.
Description
An internal description, just for you.
Tags
Use tags to organize objects throughout your Xano workspace and find them later
Request History
Inherit Settings
Use whatever is set in your workspace branch defaults
Other
Set specific request history settings for this function
Response caching
You can organize your custom functions into folders for better organization.
Folders are not required if you prefer not to use them. You can store all of your functions in folders, or use a combination of folders and no folders.
A folder requires having at least one function inside of it — empty folders are not supported.
Cache the response and redeliver it during future runs
The inputs are anything that a function stack needs to run. For example, a function stack that logs in a user probably needs a username or email and a password; these would be the inputs.
This is where all of the magic happens. All of the business logic that is performed lives here.
As you add functions to your function stack, it will suggest next steps based on most popular user activity.
Once the function stack has done its job, it needs to know what to return. This lives in the Response section.