gpt4 book ai didi

node.js - Gaxios上的此文档不支持此操作-NodeJS-Spreadsheet Google

转载 作者:行者123 更新时间:2023-12-03 12:13:30 25 4
gpt4 key购买 nike

我正在尝试根据下面的代码访问电子表格中的信息,但出现此错误,我不太了解其原因。

我已经在Google上授予了凭据电子邮件的权限...

const { google } = require("googleapis");
const creds = require("./config/gCredentials.json");

const client = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
["https://www.googleapis.com/auth/spreadsheets"]
);

client.authorize(function (err, tokens) {
if (err) {
console.log(err);
} else {
console.log("connected");
gsrun(client);
}
});

async function gsrun(cl) {
const gsapi = google.sheets({ version: "v4", auth: cl });

const opt = {
spreadsheetId: "XYZ",
range: "SheetA!A1:B14",
};

let data = await gsapi.spreadsheets.values.get(opt);
console.log(data);
}

知道可能是什么吗?

错误控制台
connected
(node:31301) UnhandledPromiseRejectionWarning: Error: This operation is not supported for this document
at Gaxios.<anonymous> (****/node_modules/googleapis/node_modules/gaxios/build/src/gaxios.js:73:27)
at Generator.next (<anonymous>)
at fulfilled (****/node_modules/googleapis/node_modules/gaxios/build/src/gaxios.js:16:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:31301) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:31301) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

最佳答案

我能够找出问题所在。该代码是正确的,但是,谷歌驱动器上的文件被保存为xlsx而不是谷歌电子表格...

我通过转到"file">“另存为Google表格”来转换电子表格。

谢谢

关于node.js - Gaxios上的此文档不支持此操作-NodeJS-Spreadsheet Google,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62433283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com