【发布时间】:2019-10-16 18:52:55
【问题描述】:
所以我创建了一个带有两个方法 checkInbox() 和 getMail() 的类 Check。
checkInbox() 检索所有邮件,getMail(msgId) 将检索带有输入 Id 的邮件。
checkInbox() 工作正常,但 getMail() 方法提供与 checkInbox() 相同的输出,即列出所有邮件而不是返回请求的邮件。
class Check{
constructor(auth){
this.me = 'mygmailid';
this.gmail = google.gmail({version: 'v1', auth});
this.auth = auth;
}
checkInbox(){
this.gmail.users.messages.list({
userId: this.me
}, (err, res) => {
if(!err){
console.log(res.data);
}
})
}
getMail(msgId){
this.gmail.users.messages.get({
'userId': this.me,
'id': msgId
}, (err, res) => {
if(!err){
console.log(res);
}
});
}
}
var obj = new dem(auth);
obj.getMail('someRandomIdNumber');
我没有附加授权码,因为它可以正常工作。导入导出类也没有错误。
【问题讨论】:
标签: javascript node.js ecmascript-6 google-api gmail-api