Created
January 29, 2021 11:41
-
-
Save LironHazan/2fc6b9b8dae200017fd07c5106610b9d to your computer and use it in GitHub Desktop.
fetchTable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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