Interface Response

Response represents the response to an API request.

interface Response {
    locals: any;
    end(data?, encoding?): void;
    getHeader(name): string;
    json(obj): void;
    redirect(url): void;
    redirect(status, url): void;
    setHeader(name, value): Response;
    status(code): Response;
    write(data, encoding?): Response;
}

Properties

locals: any

Object containing local variables scoped to a single request. Useful for exposing request-level information such as user settings.

Methods

  • Sends the HTTP response, optionally including data to write to the HTTP response body.

    Parameters

    • Optional data: string | Buffer
    • Optional encoding: string

    Returns void

  • Gets the Headers for the Response

    Parameters

    • name: string

    Returns string

  • JSON serializes an object, writes it to the HTTP response body, and sends the HTTP response.

    Parameters

    • obj: any

    Returns void

  • Mark the response to redirect the client to the provided URL with the optional status code, defaulting to 302.

    Parameters

    • url: string

    Returns void

  • Parameters

    • status: number
    • url: string

    Returns void

  • Sets a header on the HTTP response and returns the Response for chaining operations.

    Parameters

    • name: string
    • value: string

    Returns Response

  • Sets the HTTP response status code and returns a Response for chaining operations.

    Parameters

    • code: number

    Returns Response

  • Writes a string to the HTTP response body and returns the Response for chaining operations.

    Parameters

    • data: string | Buffer
    • Optional encoding: string

    Returns Response

Generated using TypeDoc