diff --git a/index.js b/index.js index 12b0639..5e4c691 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,6 @@ const GOOGLE_CLIENT_SECRET = process.env.GOOGLE_SHEETS_CLIENT_SECRET; const API_BASE_URL = process.env.API_BASE_URL; /* eslint-disable no-unused-vars */ // NOTE these variables will be used once the OAuth strategy begins, not before -const CALLBACK_URL = process.env.GOOGLE_SHEETS_URL; const PROFILE_ID = process.env.GOOGLE_SHEETS_PROFILE_ID; app.use(morgan('combined')); @@ -54,13 +53,13 @@ passport.use(new GoogleStrategy({ callbackURL: `${API_BASE_URL}/auth/google/callback`, }, - ((accessToken, refreshToken, profile, done) => { - process.env.TKN = accessToken; - process.env.PROFILE_ID = profile.id; - process.env.USERNAME = profile.displayName; +((accessToken, refreshToken, profile, done) => { + process.env.TKN = accessToken; + process.env.PROFILE_ID = profile.id; + process.env.USERNAME = profile.displayName; - done(null, profile); - }), + done(null, profile); +}), )); app.get('/auth/google', diff --git a/src/models/Sheets.js b/src/models/Sheets.js index 3e859c7..8b5e17a 100644 --- a/src/models/Sheets.js +++ b/src/models/Sheets.js @@ -26,9 +26,9 @@ class Sheets { getAllUserSheets() { return fetch(this.spreadSheetUrl) .then(getJson) - .then(response => - response.sheets.map(sheet => sheet.properties.title)) - .then(sheetNames => sheetNames.map(sheetName => fetch(`https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${sheetName}!A1:ZZ?access_token=${process.env.TKN}`))) + .then(response => response.sheets.map(sheet => sheet.properties.title)) + .then(sheetNames => sheetNames.map(sheetName => fetch(`https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${sheetName}!A1:ZZ?access_token=${process.env.TKN}`), + )) .then(promiseArray => Promise.all(promiseArray)) .then(responses => responses.map(response => response.json())) .then(responses => Promise.all(responses)) diff --git a/src/schema.js b/src/schema.js index 9ff5c1b..0cbc3d4 100644 --- a/src/schema.js +++ b/src/schema.js @@ -14,10 +14,10 @@ const schema = buildSchema(` } type Sheet { - sheetName: String range: String majorDimension: String values: [[String]] + sheetName: String } type Query {