import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts";
export async function main(
gsheets_auth: wmill.Resource<"gsheets">,
sheet_id: string,
values: Array<Array<any>>,
range: string = 'Sheet1'
) {
const body = {
"values": values,
};
const valueInputOption = "USER_ENTERED";
const insertDataOption = "INSERT_ROWS";
const includeValuesInResponse = true;
const APPEND_URL =
`https://sheets.googleapis.com/v4/spreadsheets/${sheet_id}/values/${range}:append/?valueInputOption=${valueInputOption}&insertDataOption=${insertDataOption}&includeValuesInResponse=${includeValuesInResponse}`;
const token = gsheets_auth["token"];
const response = await fetch(APPEND_URL, {
method: "POST",
body: JSON.stringify(body),
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
});
const result = await response.json();
return { result: result };
}
Submitted by thanghm104 556 days ago