fix: update examples to use the new API of cookies (#7899)

This commit is contained in:
Emanuele Stoppa 2023-08-01 15:31:55 +01:00
parent 41390c2ebd
commit dc13687bb4
3 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import Header from '../components/Header.astro';
import Container from '../components/Container.astro'; import Container from '../components/Container.astro';
import { getCart } from '../api'; import { getCart } from '../api';
if (!Astro.cookies.get('user-id').value) { if (!Astro.cookies.get('user-id')) {
return Astro.redirect('/'); return Astro.redirect('/');
} }

View file

@ -1,5 +1,5 @@
--- ---
const mode = Astro.cookies.get('prefs').json().mode; const mode = Astro.cookies.get('prefs')!.json().mode;
Astro.cookies.set('prefs', { Astro.cookies.set('prefs', {
mode: mode === 'light' ? 'dark' : 'light' mode: mode === 'light' ? 'dark' : 'light'

View file

@ -1,5 +1,5 @@
--- ---
const cookie = Astro.cookies.get('prefs'); const cookie = Astro.cookies.get('prefs')!;
const prefs = cookie.json(); const prefs = cookie.json();
--- ---
<html> <html>