[]previous and next page

after

Runs task after the response has been sent.

Runs task after the response has been sent. Call it while a request is being handled (in a loader, a server function, an API route or a middleware).

Import#

ts
import { after } from "@shadow-js/dusk/server";

Signature#

ts
function after(task: () => unknown): void

Parameters#

Name Description
task The work. Its result is ignored; a failure is reported to instrumentation.

Returns#

Nothing.

Throws#

  • DuskError SERVER_NO_REQUEST_EVENT outside a request; TypeError for a non-function; RangeError past 32 tasks.

Examples#

ts
export const GET = (event) => { after(() => analytics.track("view", event.url.pathname)); return new Response("ok"); };