Skip to content

Commit

Permalink
subscription done
Browse files Browse the repository at this point in the history
  • Loading branch information
ChikenduHillary committed Jun 20, 2024
1 parent 10e151e commit 52056d9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ document.getElementById("sub-btn").addEventListener("click", async () => {
feedback.style.display = "block";

const response = await fetch(
"http://localhost:3000/api/trpc/createSubscribers",
"https://inclusive-talks.vercel.app/api/trpc/createSubscribers",
{
method: "POST",
headers: {
Expand All @@ -30,24 +30,18 @@ document.getElementById("sub-btn").addEventListener("click", async () => {
}
);

console.log(response.body);
console.log(response.statusText);
console.log("body", response.body);
console.log("text", response.statusText);

if (response.ok) {
feedback.textContent =
"Subscription successful! You will get updates on your email";
feedback.style.color = "green";
feedback.style.display = "block";
emailInput.value = ""; // Clear the input field
} else if (response.statusText == "Method Not Allowed") {
const errorData = await response.json();
feedback.textContent = "Email already exist";
feedback.style.color = "red";
feedback.style.display = "block";
} else {
const errorData = await response.json();
feedback.textContent =
errorData.message || "Subscription failed. Please try again.";
feedback.textContent = "Email already exist";
feedback.style.color = "red";
feedback.style.display = "block";
}
Expand Down

0 comments on commit 52056d9

Please sign in to comment.