summaryrefslogtreecommitdiff
path: root/examples/ssr/src/components/AddToCart.svelte
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-03-16 12:16:21 -0400
committerGravatar GitHub <noreply@github.com> 2022-03-16 12:16:21 -0400
commit4c25a1c2eacf897427a7d6dac3bf476ef56799de (patch)
treedb1d341557694e17a07027ebea160c89bad4813d /examples/ssr/src/components/AddToCart.svelte
parent8f13b3d4068f0f017186fbc2dbd33a1427768ea4 (diff)
downloadastro-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.svelte9
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 {