Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/content/docs/workers/examples/extract-cookie-value.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import { TabItem, Tabs } from "~/components";
<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">

```js
import { parse } from "cookie";
import { parseCookie } from "cookie";
export default {
async fetch(request) {
// The name of the cookie
const COOKIE_NAME = "__uid";
const cookie = parse(request.headers.get("Cookie") || "");
const cookie = parseCookie(request.headers.get("Cookie") || "");
if (cookie[COOKIE_NAME] != null) {
// Respond with the cookie value
return new Response(cookie[COOKIE_NAME]);
Expand All @@ -47,12 +47,12 @@ export default {
</TabItem> <TabItem label="TypeScript" icon="seti:typescript">

```ts
import { parse } from "cookie";
import { parseCookie } from "cookie";
export default {
async fetch(request): Promise<Response> {
// The name of the cookie
const COOKIE_NAME = "__uid";
const cookie = parse(request.headers.get("Cookie") || "");
const cookie = parseCookie(request.headers.get("Cookie") || "");
if (cookie[COOKIE_NAME] != null) {
// Respond with the cookie value
return new Response(cookie[COOKIE_NAME]);
Expand Down