Эта операция не поддерживается для этого документа в Gax ios - NodeJS - Электронная таблица Google - PullRequest
1 голос
/ 17 июня 2020

Я пытаюсь получить доступ к информации в своей электронной таблице в соответствии с приведенным ниже кодом, и у меня возникает эта ошибка, причину которой я не совсем понимаю. 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.

1 Ответ

1 голос
/ 17 июня 2020

Мне удалось определить проблему. Код правильный, однако файл на диске Google был сохранен как xlsx, а не как электронная таблица Google ...

Я преобразовал электронную таблицу, выбрав «Файл»> «Сохранить как лист Google».

Спасибо

...