diff options
author | 2022-03-16 12:16:21 -0400 | |
---|---|---|
committer | 2022-03-16 12:16:21 -0400 | |
commit | 4c25a1c2eacf897427a7d6dac3bf476ef56799de (patch) | |
tree | db1d341557694e17a07027ebea160c89bad4813d /examples/ssr/src/components/AddToCart.svelte | |
parent | 8f13b3d4068f0f017186fbc2dbd33a1427768ea4 (diff) | |
download | astro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.tar.gz astro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.tar.zst astro-4c25a1c2eacf897427a7d6dac3bf476ef56799de.zip |
Implements redirects, headers for SSR (#2798)
* Implements redirects, headers for SSR
* Move away from an explicit Request
* Properly handle endpoint routes in the build
* chore(lint): ESLint fix
* Update based on review comments
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'examples/ssr/src/components/AddToCart.svelte')
-rw-r--r-- | examples/ssr/src/components/AddToCart.svelte | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/ssr/src/components/AddToCart.svelte b/examples/ssr/src/components/AddToCart.svelte index b03b8180a..0f7a97a93 100644 --- a/examples/ssr/src/components/AddToCart.svelte +++ b/examples/ssr/src/components/AddToCart.svelte @@ -1,11 +1,18 @@ <script> + import { addToUserCart } from '../api'; export let id = 0; + export let name = ''; - function addToCart() { + function notifyCartItem(id) { window.dispatchEvent(new CustomEvent('add-to-cart', { detail: id })); } + + async function addToCart() { + await addToUserCart(id, name); + notifyCartItem(id); + } </script> <style> button { |