GoogleSpreadsheet不是构造函数错误 [英] GoogleSpreadsheet is not a constructor error

查看:52
本文介绍了GoogleSpreadsheet不是构造函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(node:13696) UnhandledPromiseRejectionWarning: TypeError: GoogleSpreadsheet is not a constructor

当前在尝试定义GoogleSpreadsheet时出现此错误.不确定问题可能在这里.

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();

上面是我的代码,不是全部,而是与Google电子表格有关的一切.

Above is my code, not all of it, but everything to do with google spreadsheet.

推荐答案

您必须将google-spreadsheet api重新安装到2.0.6才能正常工作

You either have to re-install your google-spreadsheet api to 2.0.6 just to make it work

npm install google-spreadsheet@2.0.6

或仅遵循文档中的新版本实施 https://www.npmjs.com/package/google-spreadsheet

or just follow the new version of implementation from the docs https://www.npmjs.com/package/google-spreadsheet

这篇关于GoogleSpreadsheet不是构造函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆