getRequestEvent
The event of the request being handled.
The event of the request being handled. Available in middleware, loaders, API routes, server
functions and while a page is streamed. Where the runtime has no AsyncLocalStorage, use the
event passed as an argument (context.event in loaders).
Import#
ts
import { getRequestEvent } from "@shadow-js/dusk/server";
Signature#
ts
function getRequestEvent(): RequestEvent
Returns#
The current event.
Throws#
- DuskError
SERVER_ALS_UNAVAILABLEwhen the runtime cannot track it,SERVER_NO_REQUEST_EVENTwhen called outside a request.
Examples#
ts
const { cookies } = getRequestEvent();