【发布时间】:2021-09-05 20:45:28
【问题描述】:
我正在尝试创建一个发件人配置 nodemailer node.js,它是从 API 获取的动态数据, 示例:
let transporter = nodemailer.createTransport({
host: fromAPI,
port: fromAPI,
secure: fromAPI,
auth: {
user: fromAPI,
pass: fromAPI
}});
“fromAPI”是来自api的动态数据
我尝试从 axios 构建,但它不起作用,有什么建议吗?
axios.get('http://localhost:4500/api/email_config', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer mytoken`,
},
})
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
【问题讨论】:
-
主机的“fromAPI”是指
response.data.host等吗? -
是的,比如 response.data.host
标签: node.js api express nodemailer