Controller
renderText()
Signature
Section titled “Signature”renderText() — returns void
Available in: controller
Category: Rendering Functions
Description
Section titled “Description”Instructs the controller to render specified text when it’s finished processing the action.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | no | — | The text to render. |
status | any | no | [runtime expression] | Force request to return with specific HTTP status code. |
Examples
Section titled “Examples”// 1. Render a simple text response to the client
renderText("Done!");
// 2. Render serialized JSON data to the client
products = model("Product").findAll();
renderText(serializeJSON(products));
// 3. Render a plain-text response with a custom HTTP status code
renderText(text="Not authorized", status=401);