mavo-gsheets.js
/**
		 * If neither sheet title nor range is provided, we should use some default range to get/read data from/to.
		 * Otherwise, a request to a spreadsheet will fail, and we don't want it.
		 * Let's use all cells of the first visible sheet by default. To do that, we need to provide its title.
		 */
If neither sheet title nor range is provided, we should use some default range to get/read data from/to.
Otherwise, a request to a spreadsheet will fail, and we don't want it.
Let's use all cells of the first visible sheet by default. To do that, we need to provide its title.
If neither sheet title nor range is provided we should use some default range to get / read data from / to . Otherwise a request to a spreadsheet will fail and we don ' t want it . Let ' s use all cells of the first visible sheet by default . To do that we need to provide its title .
async findSheet (o = {}) {
			const url = _.buildURL(this.spreadsheet, { key: this.apikey });
			let response;
			if (this.isAuthenticated()) {
				response = await fetch(url.href, {
					headers: {
						Authorization: `Bearer ${this.accessToken}`
					},
				});
				if (response.status === 401) {
					await this.logout();
				}
			}
			if (!o.isStoring && !this.isAuthenticated()) {
				response = await fetch(url.href);
			}
			if (!response.ok) {
				return Promise.reject(response);
			}
			const spreadsheet = await response.json();
			const visibleSheet = spreadsheet.sheets?.find?.(sheet => !sheet.properties?.hidden);
			this.sheet = this.sheet ?? visibleSheet?.properties?.title;
		}
async findSheet ( o = { } ) { const url = _ . buildURL ( this . spreadsheet , { key : this . apikey } ) ; let response ; if ( this . isAuthenticated ( ) ) { response = await fetch ( url . href , { headers : { Authorization : ` ${ this . accessToken } ` } , } ) ; if ( response . status === 401 ) { await this . logout ( ) ; } } if ( ! o . isStoring && ! this . isAuthenticated ( ) ) { response = await fetch ( url . href ) ; } if ( ! response . ok ) { return Promise . reject ( response ) ; } const spreadsheet = await response . json ( ) ; const visibleSheet = spreadsheet . sheets ?. find ?. ( sheet => ! sheet . properties ?. hidden ) ; this . sheet = this . sheet ?? visibleSheet ?. properties ?. title ; }
If neither sheet title nor range is provided, we should use some default range to get/read data from/to.
If neither sheet title nor range is provided we should use some default range to get / read data from / to .
// Access token we have is invalid, discard it. // But in case we are getting data, we can still try an unauthenticated request. // The request failed? It doesn't make sense to proceed. // Why this.sheet in the right part of the assignment operator? // If the sheet name is a result of an expression, we want to use it instead of the title of the first visible sheet.