An overview of how to configure a loop event in your Dittofi backend. This can be used to loop through data sets and perform actions on individual rows of data.
The loop event allows you to perform the same task multiple times. In app development repetitive tasks are everywhere and loops are essential to save time and minimize errors.
For example, consider the case where you're looking to send an email to a list of users that have subscribed to your app. This could be done by getting a list of users, looping through the users and sending an email to each of the users in your list. See an example of this below.
Looping through list of users to send email
You can setup the loop event in 5 quick and easy steps.
- Step 1. create a loop endpoint
- Step 2. create a loop action
- Step 3. get a collection of records
- Step 4. add the loop event
- Step 5. add a repetitive task within the loop
- Step 6. build and test
Go to the endpoints tab and create a new endpoint by clicking on the "+ New Endpoint" button. Give the endpoint a name "/v1/loop", the description to "Looping through a collection of records" and leave the rest of the configuration the same. The final set up is shown below.
Save and close the new endpoint.
Go to the actions tab and create a new action by clicking "+ New Action".