API Requests
API requests lets you fetch and send data from an API. Toddle works with any HTTP and REST API.
Creating an API Request
To create a new API Request click the “+” button next to API Requests in the data tab.
In the API Request configuration modal you can see two panes. On the left we have to control panel that lets you configure the request. On the right you will see the data received from the request. If the API Request is set to Auto fetch then the data will automatically be re-fetched when you change the request configuration.
In the configuration panel you can change the name and different parts of the request configuration.
Auto fetch
When auto fetch is turned on, the component will automatically send the API request when the component is loaded. If any part of the API request is configured with a Formula, the component will automatically re send the request if the result of that formula changes.
Auto fetch can either be set manually, or configured with a formula. When using a formula, the request will only be sent if the formula returns TRUE.
URL
The URL section lets you change the request method as well as the base URL of the request.
If the URL will be the same every time you can simply add the url for the request in the URL input field.
If the URL will include dynamic sections then you can combine the base URL with the Path and Query inputs to construct the different parts of the URL. You can see the result in the right side panel.
Headers
Headers lets you pass additional information with a request. The headers you need to send are specified by the server that will receive the request.
Body
Requests that use the POST,PUT or PATCH may include a Request body. The request body allows you to send more information to the server. When sending data to an API, the body will normally be the main payload.
💡
GET, HEAD and OPTION requests cannot have a body
GET, HEAD and OPTION requests cannot have a body
Authorization
Authorization lets you set a authorization header for the request based on one of the authentication cookies managed by toddle.