Skip to content

Controller

renderText()

renderText() — returns void

Available in: controller Category: Rendering Functions

Instructs the controller to render specified text when it’s finished processing the action.

NameTypeRequiredDefaultDescription
textstringno—The text to render.
statusanyno[runtime expression]Force request to return with specific HTTP status code.
// 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);