Trilium Backend API
    Preparing search index...

    Interface ScriptResponse

    Minimal Express Response surface available to custom request handlers (a subset of Express's Response). Write the HTTP response through this object, e.g. api.res.status(200).json({ ok: true }).

    interface ScriptResponse {
        end(): void;
        json(body: unknown): ScriptResponse;
        redirect(url: string): void;
        send(body?: unknown): ScriptResponse;
        set(field: string, value?: string): ScriptResponse;
        setHeader(name: string, value: string | string[]): ScriptResponse;
        status(code: number): ScriptResponse;
    }
    Index
    • Ends the response without further data.

      Returns void

    • Sends a JSON response and ends the response.

      Parameters

      • body: unknown

      Returns ScriptResponse

    • Redirects to the given URL.

      Parameters

      • url: string

      Returns void

    • Sends the response body (string, Buffer, object, …) and ends the response.

      Parameters

      • Optionalbody: unknown

      Returns ScriptResponse

    • Sets a response header (Express alias of setHeader, chainable).

      Parameters

      • field: string
      • Optionalvalue: string

      Returns ScriptResponse

    • Sets a response header (chainable).

      Parameters

      • name: string
      • value: string | string[]

      Returns ScriptResponse

    • Sets the HTTP status code (chainable).

      Parameters

      • code: number

      Returns ScriptResponse