feat: initial version newsletter
This commit is contained in:
@ -2,14 +2,13 @@
|
||||
export default async (req, res) => {
|
||||
const { email } = req.body
|
||||
|
||||
console.log('hello 1')
|
||||
if (!email) {
|
||||
return res.status(400).json({ error: 'Email is required' })
|
||||
}
|
||||
|
||||
try {
|
||||
const API_KEY = process.env.NEXT_PUBLIC_BUTTONDOWN
|
||||
// console.log('Api key : ', API_KEY)
|
||||
|
||||
const response = await fetch(`https://api.buttondown.email/v1/subscribers`, {
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
@ -20,12 +19,10 @@ export default async (req, res) => {
|
||||
},
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
const badReponse = await response.json()
|
||||
// console.log('response : ', await response.json())
|
||||
const responseMessage = await response.json()
|
||||
|
||||
if (response.status >= 400) {
|
||||
return badReponse
|
||||
return res.status(500).json({ error: responseMessage[0] })
|
||||
}
|
||||
|
||||
return res.status(201).json({ error: '' })
|
||||
|
@ -5,7 +5,7 @@ import siteMetadata from '@/data/siteMetadata'
|
||||
import { getAllFilesFrontMatter } from '@/lib/mdx'
|
||||
import formatDate from '@/lib/utils/formatDate'
|
||||
|
||||
import { FormSuscribe } from '@/components/FormSuscribe'
|
||||
import { FormSubscribe } from '@/components/FormSuscribe'
|
||||
|
||||
const MAX_DISPLAY = 5
|
||||
|
||||
@ -19,7 +19,7 @@ export default function Home({ posts }) {
|
||||
return (
|
||||
<>
|
||||
<PageSEO title={siteMetadata.title} description={siteMetadata.description} />
|
||||
{siteMetadata.newsletter.provider !== '' && <FormSuscribe />}
|
||||
{siteMetadata.newsletter.provider !== '' && <FormSubscribe />}
|
||||
<div className="divide-y divide-gray-200 dark:divide-gray-700">
|
||||
<div className="pt-6 pb-8 space-y-2 md:space-y-5">
|
||||
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-6xl md:leading-14">
|
||||
|
Reference in New Issue
Block a user