MCPcopy Create free account
hub / github.com/devs-in-tech/DevsInTech / handler

Function handler

src/pages/api/subscribes.js:3–28  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

1import axios from "axios";
2
3export default async function handler(req, res) {
4 try {
5 const { email } = req.body;
6 const publicationId = process.env.NEXT_PUBLIC_PUBLICATION_ID;
7
8 // Make the API call to subscribe to the newsletter
9 const response = await axios.post(
10 "https://devsintech.hashnode.dev/api/newsletter/subscribe",
11 {
12 email,
13 publicationId,
14 }
15 );
16
17 // Handle the response from the API call
18 if (response.status === 200) {
19 res
20 .status(200)
21 .json({ message: "Subscribed to the newsletter successfully!" });
22 } else {
23 res.status(500).json({ error: "Error subscribing to the newsletter" });
24 }
25 } catch (error) {
26 res.status(500).json({ error: "Error subscribing to the newsletter" });
27 }
28}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected