Set up an API DELETE request - Xano
Last updated
Last updated
The Data Collections allows you to create API requests to any database or tool with an available REST API.
In this tutorial, we're guiding you on how to create a DELETE request to delete data in an external data source from your app. We are going to use an already existing data collection.
If you don't have a Data collection yet, go to Data Collection & Binding: Complete Collection.
👉 Figma file Sample
Here is the Figma file used in the example.
👉 Database Sample
We're using this Xano table in this example.
🏷️ Remote action tag
Ensure that the delete
element in your Figma file includes the remote action tag.
Within an API group, click on Add API Endpoint.
Select CRUD database operations.
Choose the desired table and the DELETE operation.
Finally, click on the Copy Endpoint URL.
To create a new request, click the blue "+" button.
Add a name for the request such as "Delete Scores record"
Choose the DELETE method from the request options.
Paste the URL that you have copied from Xano's API.
The URL provided contains the {scores_id}
at the end. Replace this with the variable name ${scores_id}
. This change makes it possible to delete any record the user selects by dynamically changing the ${scores_id}
variable.
To test, go to the Input Variables & Test Values tab, add the variable named scores_id
, and set the test value to 5
, which corresponds to the 5th item in the table.
Last but not least, do not forget to authenticate the request. Add the variable name _authorization
and the token as test value in Input Variables & Test Values. Generally, its the same token used in the other requests if you already have them set up.
Execute the request by clicking on the Send button.
In the Received data tab, you'll get a response as "Request was successful but no data was sent back in the response, this behaviour is set by the backend you are using. For more info regarding this request go to Debug tab
"
To verify whether an ID has been deleted, please check the Debug tool or Xano.
Under the HTTP response, receiving a null
response indicates that item 5 isn't found in the database, confirming it has been deleted successfully.
To verify in Xano, refresh the scores table and confirm that item 5 has been deleted.
Once the API request is configured, navigate to the app's binding section.
On the left-hand side, under Elements, select the delete element marked by a lightning icon, where you previously inserted the [action:remote]
tag.
After selecting the delete element, navigate to the right-hand side and locate the "Remote action" section. Here, choose the API Delete request. You can also set your preferred actions for both "On success" and "On error" scenarios.
That's it! Proceed with testing using Bravo Vision.
Now, you are ready to go!!
Your feedback is valuable to us. If you have any suggestions or questions, please don't hesitate to reach out to us in the community.