Reputation: 119
There is a simple code excerpt:
gapi.client.sheets.spreadsheets.values.get({
spreadsheetId,
range: "TOP!A:B"
}).then(result => {
doSomething()
})
How to detect and handle errors if they occur?
Errors like 503,403 etc. that are appear in response data:
{error:...}
Upvotes: 2
Views: 67
Reputation: 201553
For example, how about this modification?
gapi.client.sheets.spreadsheets.values.get({
spreadsheetId,
range: "TOP!A:B"
}).then(result => {
doSomething()
}, (error) => { // Added
if (error.status == 403) { // You can also use switch().
console.log('Status code is 403. Message: %s', error.result.error.message);
} else if (error.status == 503) {
console.log('Status code is 503. Message: %s', error.result.error.message);
}
})
If this was not what you want, I'm sorry.
Upvotes: 1