On PageLoad event handler
In order to trigger an action when an application loads, such as fetching data from a database and displaying it in a frontend table, use the on PageLoad event handler.
The on PageLoad event handler allows you to run any Backend API when a user opens or refreshes an Application in Superblocks.
Configure an API to run when the page loads
You can configure a Backend API to run on PageLoad using the API's trigger block as described here.
Run frontend JavaScript when the page loads
You can use the on PageLoad event handler that triggers backend APIs to execute JavaScript on the frontend of your application when a user opens or refreshes it.
Add Backend API, and name it something obvious, in this example on PageLoad. Configure the API trigger block to
Always
run on page load:Add a dummy step, in this example Python that runs
return True
:Configure the API response block and then configure the onSuccess event handler to
RunJS
. This is where we can execute any JavaScript and also many other things when a page loads: