In this chapter, we will not cover all aspects of server-side coding, but simply summarize some basic technical elements that you should take care of.
There are several languages / Frameworks available to develop a server-side API (php, asp, node.js…), but we will focus on a simple example with php-mysql.
This exemple is very basic, the goal is to explain the basics, and the code could obviously be improved
Let’s say you want to create an API that will return the data from a MYSQL Table with customers information and allow a search on the customer country:
Step 1 The first thing to do is to get the parameters sent to the API, in our example, we will just add a filter for the customer country:
Step2 Connect to the Database and execute the SQL
Step3 Loop on the results and populate an Array, and convert the result Array to JSON
Step4 Set the header for the result and return the JSON
The access-control-origin header must obviously be changed depending on your own security control check.
The Json API Repeaters & Displayers are using the fetch API ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API )
If you need to manipulate the options & headers sent to the server, please read this tutorial: https://www.thoriumbuilder.com/tutorial_detail.html?id=162529280