0
Get Values
One script reply has been approved by the moderators Verified
Created by rossmccrann 849 days ago Viewed 18602 times
0
Submitted by rossmccrann Deno
Verified 849 days ago
1
type Gsheets = {
2
  token: string;
3
};
4
export async function main(
5
  gsheets_auth: Gsheets,
6
  spreadsheetId: string,
7
  worksheet_name: string,
8
) {
9
  const token = gsheets_auth["token"];
10

11
  const GET_VALUES_URL = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${worksheet_name}`;
12

13
  const response = await fetch(GET_VALUES_URL, {
14
    method: "GET",
15
    headers: {
16
      Authorization: "Bearer " + token,
17
      "Content-Type": "application/json",
18
    },
19
  });
20

21
  return await response.text();
22
}
23