最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - GoogleSpreadsheet is not a constructor error - Stack Overflow

programmeradmin5浏览0评论
(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
Add a ment  | 

2 Answers 2

Reset to default 4

If 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

发布评论

评论列表(0)

  1. 暂无评论