Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Last active October 10, 2022 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulieScanlon/077f51fffa49cdaf7006d4ca501e436f to your computer and use it in GitHub Desktop.
Save PaulieScanlon/077f51fffa49cdaf7006d4ca501e436f to your computer and use it in GitHub Desktop.
Read and Update the Google Sheet
...
export default async function handler(req, res) {
...
try {
...
+ await doc.getInfo();
+ const sheet = doc.sheetsByIndex[0];
+ const rows = await sheet.getRows();
+ const raw_data = rows[0]._rawData;
+ const header_values = rows[0]._sheet.headerValues;
+ const row_value = rows[0][id];
+
+ rows[0][id] = Number(row_value) + 1;
+ await rows[0].save();
+
...
} catch (error) {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment