我使用 passport-google-oauth 进行身份验证和node-gmail-api
获取 gmail !所以我想在经过身份验证后显示 gmail 消息,以便我这样编码routes.js
app.get('/profile', isLoggedIn, function(req, res) {
var gmail = new Gmail(req.user.google.token)
, s = gmail.messages('label:inbox', {max: 10}),mm;
s.on('data', function (d) {
res.render('profile.ejs', {
user : req.user, // get the user out of session and pass to template,
mm: d.snippet,
layout: 'header'
});
})
关于代码可以获取 gmail 消息但出现如下错误并停止节点服务器运行
错误:发送后无法设置标头。
在 validateHeader (_http_outgoing.js:494:11)
在 ServerResponse.setHeader (_http_outgoing.js:501:3)
.....
res.render
如果我在函数之外编写s.on('data')
,则无法在 render 中传递邮件片段字符串。如何使用node-gmail-api
message 正确呈现?