Queries
Be it a database table or an external API, Toolpad offers mechanisms to bring server-side data to the page.
You can create two kinds of queries in Toolpad to bring data to your page.
- HTTP request
- Custom functions
Mode
You can set the mode of the query to either be automatically refetched on page load, or only be called on manual action.
Setting the query mode
Automatic
You can configure the following settings in this mode:
Enabled
You can use this option to enable or disable the query from running
Refetch interval
You can configure the query to run on an interval, for example every 30s. To disable this option, keep the field empty.
Queries set to the automatic mode may be re-fetched via the
refetch
function available on these query objects. For example, for a query namedgetOrders
, we can addgetOrders.refetch();
in the
onClick
binding of a Button component.Manual
Queries set to this mode can be called via a JavaScript expression in a binding. For example, for a query named
createCustomer
, we can addcreateCustomer.call();
in the
onClick
binding of a Button component. This will trigger this query when the Button is clicked.