Add form section
This commit is contained in:
parent
c6705914e0
commit
2a4cf52465
33 changed files with 1031 additions and 311 deletions
65
server/api/mailjet.post.js
Normal file
65
server/api/mailjet.post.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
import Mailjet from 'node-mailjet';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
|
||||
const body = await readBody(event);
|
||||
|
||||
// const mailjet = new Mailjet({
|
||||
// apiKey: useRuntimeConfig().mailjetApiPublic,
|
||||
// apiSecret: useRuntimeConfig().mailjetApiPrivate
|
||||
// });
|
||||
|
||||
// const request = mailjet
|
||||
// .post('send', { version: 'v3.1' })
|
||||
// .request({
|
||||
// Messages: [
|
||||
// {
|
||||
// From: {
|
||||
// Email: 'contact@paulnicoue.com',
|
||||
// Name: body.name,
|
||||
// },
|
||||
// To: [
|
||||
// {
|
||||
// Email: 'contact@paulnicoue.com',
|
||||
// Name: 'Paul Nicoué',
|
||||
// },
|
||||
// ],
|
||||
// Subject: body.subject,
|
||||
// TextPart: body.message
|
||||
// }
|
||||
// ]
|
||||
// });
|
||||
|
||||
// request
|
||||
// .then(result => {console.log(result.body)})
|
||||
// .catch(err => {console.log(err.statusCode)});
|
||||
|
||||
Mailjet
|
||||
.apiConnect(
|
||||
useRuntimeConfig().mailjetApiPublic,
|
||||
useRuntimeConfig().mailjetApiPrivate
|
||||
)
|
||||
.post('send', { version: 'v3.1' })
|
||||
.request({
|
||||
Messages: [
|
||||
{
|
||||
From: {
|
||||
Email: 'contact@paulnicoue.com',
|
||||
Name: body.name,
|
||||
},
|
||||
To: [
|
||||
{
|
||||
Email: 'contact@paulnicoue.com',
|
||||
Name: 'Paul Nicoué',
|
||||
},
|
||||
],
|
||||
Subject: body.subject,
|
||||
TextPart: body.message
|
||||
}
|
||||
]
|
||||
})
|
||||
.then((result) => console.log(result.body))
|
||||
.catch((err) => console.log(err.statusCode));
|
||||
|
||||
return event.node.res.end();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue