Dev Helpers
← Back

Read a request context

Read a request context using Node.js.

Open this example in the interactive library

Source code

import {
  AsyncLocalStorage,
  AsyncResource,
  executionAsyncId,
} from "node:async_hooks";
const context = new AsyncLocalStorage();
console.log(context.run({ id: 7 }, () => context.getStore().id));

Sample output

7