blob: 0a082eeeb55eef862886cacbfde02a1f66cdca43 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { NextApiRequest, NextApiResponse } from "next";
import { withSentry } from "@sentry/nextjs";
const CAMPAIGN_ID = process.env.TURBOREPO_SFDC_CAMPAIGN_ID;
const TRAY_URL = process.env.TRAY_URL;
async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
const user = {
email: req.body.email,
campaign_id: CAMPAIGN_ID,
};
try {
const trayRes = await fetch(TRAY_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ user: user }),
});
return res.status(201).json(user);
} catch (error) {
return res.status(500).json(error);
}
} else {
return res.status(404).send(null);
}
}
export default withSentry(handler);
|