aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/node/test/fixtures/sessions/src/pages/api.ts
blob: 21793c78a74f40e72ec5daf8fbfcf076f00eea90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import type { APIRoute } from 'astro';

export const GET: APIRoute = async (context) => {
	const url = new URL(context.url, 'http://localhost');
	let value = url.searchParams.get('set');
	if (value) {
		 context.session.set('value', value);
	} else {
		value = await context.session.get('value');
	}
	const cart = await context.session.get('cart');
	return Response.json({ value, cart });
};