Skip to content

Commit 51c5b0d

Browse files
committed
fix: support templates w/o data
1 parent 3834cfa commit 51c5b0d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

content/email_templates/show.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.get('/:templateName', function (req, res) {
1414
if (templateName.includes('.')) return;
1515
const {data} = req.query;
1616
const template = fs.readFileSync(`content/email_templates/${templateName}.html`, {encoding: 'utf8'});
17-
const content = injectData(layout.replace('$$$Content$$$', template), JSON.parse(data));
17+
const content = injectData(layout.replace('$$$Content$$$', template), JSON.parse(data || '{}'));
1818
res.send(content);
1919
});
2020

src/modules/email/email.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class EmailService {
4646
}
4747

4848
async sendLocalTemplate(params: EmailParams) {
49-
const { to, subject, data, name } = params;
49+
const { to, subject, data = {}, name } = params;
5050
const content = await this.injectData(name, data);
5151
try {
5252
await sgMail.send({

0 commit comments

Comments
 (0)