From af046fab88908b29b2316abf6ca0eb91abf15022 Mon Sep 17 00:00:00 2001 From: Michael van Leest <1381694+mvanleest@users.noreply.github.com> Date: Sun, 15 Dec 2024 02:44:03 +0100 Subject: [PATCH] fix: Astro client example fix callback.ts (#79) The current example gives an error in v0.2.0 and up. Updated to work again --- examples/client/astro/src/pages/callback.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/client/astro/src/pages/callback.ts b/examples/client/astro/src/pages/callback.ts index 5367e89..d9512f4 100644 --- a/examples/client/astro/src/pages/callback.ts +++ b/examples/client/astro/src/pages/callback.ts @@ -5,7 +5,11 @@ export const GET: APIRoute = async (ctx) => { const code = ctx.url.searchParams.get("code") try { const tokens = await client.exchange(code!, ctx.url.origin + "/callback") - setTokens(ctx, tokens.access, tokens.refresh) + if (!tokens.err) { + setTokens(ctx, tokens.tokens.access, tokens.tokens.refresh) + } else { + throw tokens.err + } return ctx.redirect("/", 302) } catch (e) { return Response.json(e, {