TypeError:无法读取未定义的属性'gmail' [英] TypeError: Cannot read property 'gmail' of undefined
问题描述
let fs = require('fs');
让google = require('googleapis');
$ b $ getMessage(userId,messageId,callback){
let gmail = this.getGmailService();
var request = google.client.gmail.users.messages.get({$ b $'userId':userId,
'id':messageId
});
request.execute(callback);
}
当我从规范中调用这个方法时
getMessage('abcd123987@gmail.com','15934550ay626ud09')
它吐出以下错误:
TypeError:无法读取属性'gmail'的undefined
有什么意见/建议吗?
有3个选项:
1.您没有安装googleapis节点模块。
2.您没有很好地导入它。
3.您没有使用它。
选项1修正:
安装googleapis节点模块:
yarn add googleapis
选项2修正:
在googleapis(V26)的新版本中,我需要将我的导入行更改为以下内容:
var {google } = require('googleapis');
选项3修正:
您可以通过google.client.gmail调用它,也许只需使用google.gmail
let fs = require('fs');
let google = require('googleapis');
getMessage(userId, messageId, callback) {
let gmail = this.getGmailService();
var request = google.client.gmail.users.messages.get({
'userId': userId,
'id': messageId
});
request.execute(callback);
}
when I call this method from a spec
getMessage('abcd123987@gmail.com', '15934550ay626ud09')
it spits out the following error
TypeError: Cannot read property 'gmail' of undefined
any comments/suggestions?
There are 3 options: 1. You didn't install the googleapis node module. 2. You didn't import it well. 3. You didn't use it well.
Option 1 fix: Install the googleapis node module: yarn add googleapis
Option 2 fix: In the new version of googleapis (V26) I needed to change my import line to the following: var {google} = require('googleapis');
Option 3 fix: You are calling it via google.client.gmail, perhaps use just google.gmail
这篇关于TypeError:无法读取未定义的属性'gmail'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!