Each time you need to send or receive data using an API – you will make a request. With an API added to your project, you will see a drop-down list in the API tab on the right of the editor showing the available endpoints. To use a request in a page:
- Add a request to the page by selecting an endpoint.
- Add an Action to specify when the request should run.
- Open the request to connect parameters and responses to your UI and functionality.
Dropsource supports a variety of request types for retrieving, adding, updating, and deleting data, including GET, POST, PUT, PATCH, and DELETE.
Select one from the list and click Add to use it in a particular page. Once added the endpoint will appear in the API tab as a request you can configure.
Click a request to open it. From here you can specify parameters to send, display responses in the page, and add processing to execute when the response is received.
If you decide not to use a request in a particular page, click to open it, then use the Delete button.
Once you have an endpoint added to a page in your app, you need to specify when you want the request to run. This will be when an Event occurs in your app, such as the user tapping a button, or the page loading. You will typically run the request on user interaction if the parameters include data entered by the user, and on page load if the request has all of the information it needs to run straight away.
Select the relevant Element or page (in the Canvas or Element Tree) and open Properties > Events. Add an Action to your chosen Event, for example Tapped or Page Loaded.
Add the Run API Request Action, selecting the endpoint, an optional request cache mode (and cache expiration).
You can use the cache to minimize the number of times you need to send a request to your API and to cope with situations where the user device has no network connection. Use the cache modes to control when the app will fetch new data and when it will display cached data.
You can also detect and respond to network connectivity changes using the Network Connection Changed Event you will see on each page for your app.
Any Actions you add to this Event can access connectivity status using the Event Data, allowing you to add processing in response to whether or not the user device is currently connected.
The Network Connection Changed Event will fire whenever the connection status changes on any page of your app – and when the landing page of your app loads. A common use of this is to e.g. set a boolean Device Variable and update it to monitor the network status on each page of your app.
If you’re having problems with a request you’ve added to a Dropsource app, check out our troubleshooting guide.