Skip to content

Instantly share code, notes, and snippets.

@neil-lobo
Created January 20, 2025 18:26
Show Gist options
  • Save neil-lobo/e632aae751fe7aec8bbc29a42c585015 to your computer and use it in GitHub Desktop.
Save neil-lobo/e632aae751fe7aec8bbc29a42c585015 to your computer and use it in GitHub Desktop.
const { google } = require("googleapis");
const fs = require("node:fs");
google.options({
http2: true,
});
const auth = new google.auth.GoogleAuth({
credentials: JSON.parse(fs.readFileSync("credentials.json").toString()),
scopes: ["https://www.googleapis.com/auth/spreadsheets"],
});
const client = google.sheets({
version: "v4",
auth,
});
async function main() {
let res;
res = await client.spreadsheets.values.get({
spreadsheetId: "[sheet ID]",
range: "A1:B1",
});
console.log("finish get", res.status);
res = await client.spreadsheets.values.clear({
spreadsheetId: "[sheet ID]",
range: "A1:B1",
});
console.log("finish clear", res.status);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment