How do I run JS-Objects on page load?

Requirements:

  • Can I store appsmith local variables on page load?
  • Can we run a few functions to display the data on widgets on page load?

We’ve recently shipped a feature that lets us run JS Objects on page-load. All the functions and variables on the JS Object will run on page load.

To enable this, click on the cog icon next to the function name on the Response tab:

You’ll see a Modal that lets you enable onPageLoad actions; you could choose to toggle it based on your requirement:

This feature is available on the cloud and will be soon shipped to self-hosted versions.