(node:13696) UnhandledPromiseRejectionWarning: TypeError: GoogleSpreadsheet is not a constructor
Currently getting this error when trying to define GoogleSpreadsheet. Not sure what the issue could be here.
async function accessSpreadsheet() {
const doc = new GoogleSpreadsheet('166SrAlBzhYXLxxIrHCQR333y_w3pcxeG7rV3bkjAp2U');
await promisify(doc.useServiceAccountAuth)(creds);
const info = await promisify(dox.getInfo)();
const sheet = info.worksheets[0];
const input = {
transcript: data,
ticket: message.channel.name
}
await promisify(sheet.addRow);
}
accessSpreadsheet();
Above is my code, not all of it, but everything to do with google spreadsheet.
(node:13696) UnhandledPromiseRejectionWarning: TypeError: GoogleSpreadsheet is not a constructor
Currently getting this error when trying to define GoogleSpreadsheet. Not sure what the issue could be here.
async function accessSpreadsheet() {
const doc = new GoogleSpreadsheet('166SrAlBzhYXLxxIrHCQR333y_w3pcxeG7rV3bkjAp2U');
await promisify(doc.useServiceAccountAuth)(creds);
const info = await promisify(dox.getInfo)();
const sheet = info.worksheets[0];
const input = {
transcript: data,
ticket: message.channel.name
}
await promisify(sheet.addRow);
}
accessSpreadsheet();
Above is my code, not all of it, but everything to do with google spreadsheet.
Share Improve this question edited Apr 5, 2020 at 20:42 Radix 2,7771 gold badge22 silver badges44 bronze badges asked Apr 5, 2020 at 19:28 Malek AlashkarMalek Alashkar 411 silver badge4 bronze badges 1- Please can you show your includes? – Rafa Guillermo Commented Apr 6, 2020 at 13:27
2 Answers
Reset to default 4If you are using version 3 you may need to import it like this:
const { GoogleSpreadsheet } = require('google-spreadsheet');
You either have to re-install your google-spreadsheet api to 2.0.6 just to make it work
npm install [email protected]
or just follow the new version of implementation from the docs https://www.npmjs./package/google-spreadsheet