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('[email protected]', '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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With