Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
bug: fix js
Browse files Browse the repository at this point in the history
Signed-off-by: Kieran Klukas <[email protected]>
  • Loading branch information
taciturnaxolotl authored Jun 1, 2024
1 parent b12dc85 commit 7cb2326
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (Astro.request.method === "POST") {
const data = await Astro.request.formData();
const name = data.get("name");
const email = data.get("email");
fetch('https://catapult.purplebubble.org/api/subscribe', {
const response = await fetch('https://catapult.purplebubble.org/api/subscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -17,15 +17,13 @@ if (Astro.request.method === "POST") {
const jsondata = await response.json();
if (jsondata.ok = true){
//do nothing
}else{
} else{
error = jsondata.error;
}
}
catch (error) {
if (error instanceof Error) {
error && (
<p class="text-red-500">Error: {error}</p>
)
console.log(error)
}
}
}
Expand Down Expand Up @@ -53,6 +51,9 @@ if (Astro.request.method === "POST") {
</p>
</section>
<section>
{error && (
<p class="text-red-500">Error: {error}</p>
)}
<form
action="https://postal.hackclub.com/subscribe"
method="POST"
Expand Down

0 comments on commit 7cb2326

Please sign in to comment.