Step 5: Send response

Having completed the processing, the server sends the response back to the client.

The server application has the value or values that must be returned to the client. It now needs to format and send the response.

In the demo server application, the setResponseHeader() method sets the Content-Type to JSON.

CALL req.setResponseHeader("Content-Type","application/json")
The sendTextResponse() sends three things: a code, a description, and the response data. In this case, the data is formatted as JSON using the util.JSON.stringify() method, which transforms a record variable into a flat JSON formatted string.
CALL req.sendTextResponse(200, "OK", util.JSON.stringify(add_out))