Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何使用axios从电子表格中获取数据?_Google Apps Script_Google Sheets_Axios - Fatal编程技术网

Google apps script 如何使用axios从电子表格中获取数据?

Google apps script 如何使用axios从电子表格中获取数据?,google-apps-script,google-sheets,axios,Google Apps Script,Google Sheets,Axios,我有一段代码,它从google电子表格中获取数据,并返回JSON。 我尝试用我的google电子表格文档实现相同的功能,但由于某种原因,它返回403错误 还有可能再提出这样的请求吗?如果是,我怎样才能提出这样的要求? 谷歌电子表格API似乎得到了更新 import axios from 'axios'; let data = null; function fetch() { const spreadsheetID = "id_of_the_spreadsheet_document";

我有一段代码,它从google电子表格中获取数据,并返回JSON。 我尝试用我的google电子表格文档实现相同的功能,但由于某种原因,它返回403错误

还有可能再提出这样的请求吗?如果是,我怎样才能提出这样的要求? 谷歌电子表格API似乎得到了更新

import axios from 'axios';

let data = null;

function fetch() {
  const spreadsheetID = "id_of_the_spreadsheet_document";
  const url = `https://spreadsheets.google.com/feeds/list/${spreadsheetID}/od6/public/values?alt=json`;

  return axios.get(url)
    .then(res => {
      data = res.data.feed.entry
      // do data transformation here  
      // then simply return it
      return data;
    });
}

export default {
  fetch,
  get: () => data,
}

通知您没有访问该工作表所需的权限。您应该使用电子表格API管理令牌关系。您可以按照以下步骤进行操作,从中可以找到可操作的示例,稍后可以修改这些示例以添加代码。如果您有任何疑问,请询问我。

403错误表示“禁止”,这可能表明您没有访问电子表格的权限。您是否检查过API中的任何类型的身份验证?