diff --git a/src/routes/api/subscribe/+server.ts b/src/routes/api/subscribe/+server.ts index dff594b..f03b008 100644 --- a/src/routes/api/subscribe/+server.ts +++ b/src/routes/api/subscribe/+server.ts @@ -15,8 +15,9 @@ export const POST: RequestHandler = async ({ request, cookies, locals: { safeGet const userId = session.user.id; const userEmail = session.user.email; - // Get the price ID from the request body - const { priceId } = await request.json(); + // Get the price ID from the request form data + const formData = await request.formData(); + const priceId = formData.get('priceId'); if (!priceId) { return new Response('Price ID is required', { status: 400 }); diff --git a/src/routes/products/[productId]/+page.svelte b/src/routes/products/[productId]/+page.svelte index a481043..54c6e1d 100644 --- a/src/routes/products/[productId]/+page.svelte +++ b/src/routes/products/[productId]/+page.svelte @@ -50,20 +50,6 @@ }); }, 5000); } - - function startSubscription() { - fetch('/api/subscribe', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ priceId: item.priceId }) - }) - .then((response) => response.json()) - .then((data) => { - console.log(data); - }); - }
@@ -85,7 +71,8 @@
- £{item.price} {item.isSubscription ? `/ ${item.interval}` : ''} + £{item.price} + {item.isSubscription ? `/ ${item.interval}` : ''}
@@ -373,12 +360,15 @@ {/if} {#if item.isSubscription}
- +
+ + +
{/if} {/if}