forked from mrwyndham/fastpocket
35 lines
1021 B
JavaScript
35 lines
1021 B
JavaScript
const fetch = require('node-fetch-commonjs')
|
|
|
|
exports.handler = async function (event) {
|
|
if (event.body === null) {
|
|
return {
|
|
statusCode: 400,
|
|
body: JSON.stringify("Payload required"),
|
|
};
|
|
}
|
|
|
|
const requestBody = JSON.parse(event.body)
|
|
|
|
//automatically generated snippet from the email preview
|
|
//sends a request to an email handler for a subscribed email
|
|
await fetch(`${process.env.URL}/.netlify/functions/emails/BookNow`, {
|
|
headers: {
|
|
"netlify-emails-secret": process.env.NEXT_PUBLIC_NETLIFY_EMAILS_SECRET,
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
from: process.env.NEXT_PUBLIC_NETLIFY_FROM_EMAIL,
|
|
to: requestBody.subscriberEmail,
|
|
subject: "Thanks For Booking on Sign365",
|
|
parameters: {
|
|
email: requestBody.subscriberEmail,
|
|
},
|
|
}),
|
|
}
|
|
);
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify("SignUp email sent!"),
|
|
};
|
|
} |