Skip to content

Commit

Permalink
fix: newsletter
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartek532 committed Jun 25, 2024
1 parent 99570eb commit 32d957a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/tile/newsletter/api/mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { env } from "env/server";

export const subscribeToNewsletter = async (email: string) => {
await fetch("https://connect.mailerlite.com/api/subscribers", {
const response = await fetch("https://connect.mailerlite.com/api/subscribers", {
method: "POST",
body: JSON.stringify({ email, groups: [env.MAILER_LITE_GROUP_ID] }),
headers: {
Expand All @@ -12,4 +12,8 @@ export const subscribeToNewsletter = async (email: string) => {
Accept: "application/json",
},
});

if (!response.ok) {
throw new Error("Failed to subscribe to newsletter!");
}
};

0 comments on commit 32d957a

Please sign in to comment.