Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created January 29, 2021 11:41
Show Gist options
  • Save LironHazan/2fc6b9b8dae200017fd07c5106610b9d to your computer and use it in GitHub Desktop.
Save LironHazan/2fc6b9b8dae200017fd07c5106610b9d to your computer and use it in GitHub Desktop.
fetchTable.ts
function fetchTable<T>(sheets: Sheets, range: any, spreadsheetId: any): Promise<Either<Error, unknown>> {
return new Promise((resolve, reject) => {
sheets.spreadsheets.values.get({ spreadsheetId, range }, (err, res) => {
if (err || !res.data) {
console.log('The API returned an error: ' + err);
return reject(err);
}
return resolve(tableAsJson(res.data.values, range));
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment