From dc13687bb45fdd21e1aded198230f19854b40f17 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 1 Aug 2023 15:31:55 +0100 Subject: [PATCH] fix: update examples to use the new API of cookies (#7899) --- examples/ssr/src/pages/cart.astro | 2 +- .../test/fixtures/astro-cookies/src/pages/early-return.astro | 2 +- .../astro/test/fixtures/astro-cookies/src/pages/get-json.astro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/ssr/src/pages/cart.astro b/examples/ssr/src/pages/cart.astro index ebc2f1472..40e5cf126 100644 --- a/examples/ssr/src/pages/cart.astro +++ b/examples/ssr/src/pages/cart.astro @@ -3,7 +3,7 @@ import Header from '../components/Header.astro'; import Container from '../components/Container.astro'; import { getCart } from '../api'; -if (!Astro.cookies.get('user-id').value) { +if (!Astro.cookies.get('user-id')) { return Astro.redirect('/'); } diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/early-return.astro b/packages/astro/test/fixtures/astro-cookies/src/pages/early-return.astro index 2796b3989..1457cb882 100644 --- a/packages/astro/test/fixtures/astro-cookies/src/pages/early-return.astro +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/early-return.astro @@ -1,5 +1,5 @@ --- -const mode = Astro.cookies.get('prefs').json().mode; +const mode = Astro.cookies.get('prefs')!.json().mode; Astro.cookies.set('prefs', { mode: mode === 'light' ? 'dark' : 'light' diff --git a/packages/astro/test/fixtures/astro-cookies/src/pages/get-json.astro b/packages/astro/test/fixtures/astro-cookies/src/pages/get-json.astro index 034881d22..44ee024ae 100644 --- a/packages/astro/test/fixtures/astro-cookies/src/pages/get-json.astro +++ b/packages/astro/test/fixtures/astro-cookies/src/pages/get-json.astro @@ -1,5 +1,5 @@ --- -const cookie = Astro.cookies.get('prefs'); +const cookie = Astro.cookies.get('prefs')!; const prefs = cookie.json(); ---