Api process request from client and output data object as JSON. You can export a JSON object or a Mock JSON string.
JSON object
Use kScript to query object from SiteDb or Database and export the object as json to client.
var obj = {};
obj.name = "myname";
obj.fieldtwo = "value of field two";
k.response.setHeader("Access-Control-Allow-Origin", "*");
k.response.json(obj);
Result is a JSON string
{
"name": "myname",
"fieldtwo": "value of field two"
}
Mock Api
If the Api is not ready yet and you want to provide sample Api response for client, you may input JSON data directly into the API body, it will output as it is.
Put the following code into Api body
{
"name": "myname",
"value": "my value"
}
output:
{
"name": "myname",
"value": "my value"
}