Search... Ctrl + K

List Worksheets (gsheets)
One script reply has been approved by the moderators Verified

Created by rossmccrann 127 days ago Used 27 times 1 Point

No comments yet

Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import * as wmill from "https://deno.land/x/windmill@v1.24.1/mod.ts";

export async function main(gsheets_auth: wmill.Resource<"gsheets">,
    spreadsheetId: string,
) {

    const token = gsheets_auth["token"];

    const GET_WORKSHEET_URL =
        `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}?&fields=sheets.properties`;


    const response = await fetch(GET_WORKSHEET_URL, {
        method: "GET",
        headers: {
            Authorization: "Bearer " + token,
            "Content-Type": "application/json",
        },
    });
    const text = await response.json()

    let list = [];
    for (let i in text['sheets']) {
        list.push({ sheetId: text['sheets'][i]['properties']['sheetId'], title: text['sheets'][i]['properties']['title'] })
    }

    return list;
}

Submitted by rossmccrann 127 days ago

Edited 127 days ago

No comments yet