A new start
This commit is contained in:
22
packages/frontend/src/routes/newsletter/+server.ts
Normal file
22
packages/frontend/src/routes/newsletter/+server.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
LETTERSPACE_API_KEY,
|
||||
LETTERSPACE_API_URL,
|
||||
LETTERSPACE_LIST_ID,
|
||||
} from "$env/static/private";
|
||||
import { json } from "@sveltejs/kit";
|
||||
|
||||
export async function POST({ request, fetch }) {
|
||||
const { email } = await request.json();
|
||||
const lists = [LETTERSPACE_LIST_ID];
|
||||
|
||||
await fetch(`${LETTERSPACE_API_URL}/subscribers`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": LETTERSPACE_API_KEY,
|
||||
},
|
||||
body: JSON.stringify({ email, lists }),
|
||||
});
|
||||
|
||||
return json({ email }, { status: 201 });
|
||||
}
|
||||
Reference in New Issue
Block a user