Search.../

sendStatus( )

Returns a response with the specified HTTP status code with an optional message.

Description

The sendStatus() function is used in the router(), beforeRouter(), and afterRouter() hooks to return a specified response. Optionally, you can pass a message.

Syntax

function sendStatus(statusCode: string, [message: string]): Promise<WixRouterResponse>

sendStatus Parameters

NAME
TYPE
DESCRIPTION
statusCode

string

The HTTP status code to return.

message
Optional

string

The message to write as the HTTP body.

Returns

Fulfilled - A response object with the specified HTTP status.

Return Type:

Was this helpful?

Create a response with a specified status code

Code Example

Copy Code
1import {sendStatus} from 'wix-router';
2
3export function myRouter_Router(request) {
4
5 return sendStatus("418");
6}
Create a response with a specified status code and message

Code Example

Copy Code
1import {sendStatus} from 'wix-router';
2
3export function myRouter_Router(request) {
4
5 return sendStatus("418", "Message");
6}