Edits history of script submission #71 for ' Append Rows (gsheets)'

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(gsheets_auth: wmill.Resource<"gsheets">,
        spreadsheetId: string,
        range: string,
        values: Array<any>,
    ) {
    
        const token = gsheets_auth["token"];
        const valueInputOption = 'USER_ENTERED';
        const APPEND_ROWS_URL =
            `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}:append?valueInputOption=${valueInputOption}`;
    
        const body = {
            "range": range,
            "majorDimension": "ROWS",
            "values": [values],
        };
    
        const response = await fetch(APPEND_ROWS_URL, {
            method: "POST",
            body: JSON.stringify(body),
            headers: {
                Authorization: "Bearer " + token,
                "Content-Type": "application/json",
            },
        });
    
        const text = await response.text()
    
        return text;
    }

    Submitted by rossmccrann 1429 days ago