Skip to content

Commit

Permalink
fix: update google spreadsheet api
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirajn2311 committed Nov 2, 2021
1 parent e710ebd commit 815efb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
npm install
npm run build
env:
REACT_APP_BACKEND_URL: ${{ secrets.REACT_APP_BACKEND_URL }}
REACT_APP_BACKEND_URL: ${{ secrets.REACT_APP_BACKEND_URL }}
REACT_APP_SHEETS_API_KEY: ${{ secrets.REACT_APP_SHEETS_API_KEY }}

- name: Deploy 🚀
uses: JamesIves/[email protected]
Expand Down
17 changes: 8 additions & 9 deletions src/_services/spreadSheetApi.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
class SpreadSheetApi {
async getWorkSheetData(workSheetId) {
const url = `https://spreadsheets.google.com/feeds/list/${workSheetId}/od6/public/values?alt=json`;
const url = `https://sheets.googleapis.com/v4/spreadsheets/${workSheetId}/values/Sheet1?key=${process.env.REACT_APP_SHEETS_API_KEY}`;
const data = await (await fetch(url)).json();
const keys = data.values.shift();

return data.feed.entry.map(entry => {
let obj={};
Object.keys(entry)
.filter(key => key.startsWith('gsx$'))
.forEach(key => {
obj[key.replace('gsx$','')]=entry[key]['$t'];
})
return data.values.map(entry => {
let obj = {};
entry.forEach((item, j) => {
obj[keys[j]] = item;
});
return obj;
});
}
}

var instance = new SpreadSheetApi();
export default instance;
export default instance;
4 changes: 2 additions & 2 deletions src/environment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const membersWorkSheetId = '1lGGGhwkitKwHqFijYE8bbMv4WF8d-8-GgqJN1N8JlyI';
export const eventsWorkSheetId = '13n5gxO8RXD3mSjoa93UnOx_YOaCLAqBFTFjoy256WgY';
export const membersWorkSheetId = '1GZq0CoE1AiRlOTYj0fAkUFVtvckLjkE4ggVIW1LwHHo';
export const eventsWorkSheetId = '1GhmmeCZQYMlsJuA8ydMNoNNEloSI4ete9juk89RKXzg';
export const timelineWorkSheetId = '1ccSHjT7jpYFY1mvBzwpAbr9XJwuLKwX51k7eQ3K1PSk';
export const profileImagesRepositoryURL = 'https://raw.githubusercontent.com/WebClub-NITK/Profile-Photos/main/Web%20Club%20Members%20Profile%20Photos/';

0 comments on commit 815efb2

Please sign in to comment.