【发布时间】:2020-07-24 15:49:04
【问题描述】:
我有以下结构可以使用SendGrid 发送电子邮件:
import mail from '@sendgrid/mail';
function send(email_data) {
mail.setApiKey(process.env.SENDGRID_API_KEY);
const message = {
to: email_data.to,
from: email_data.from,
subject: email_data.subject,
text: email_data.text,
};
return mail.send(message);
}
export default send;
在我的控制器中,我按如下方式调用该方法:
const email_data = {
to: 'myemail@hotmail.com',
from: 'some_other_email@gmail.com',
subject: 'Deposito realizado',
text: 'Foi feito um deposito na sua conta ...',
};
mail.send(email_data);
但是向我显示以下错误:
(node:7963) UnhandledPromiseRejectionWarning: TypeError: _sendgrid2.default.send is not a function
【问题讨论】:
标签: javascript node.js sendgrid