Permalink
Browse files

You can now use 'id' param as 'REACT_APP_SPREADSHEET_ID'

  • Loading branch information...
marcomontalbano committed Dec 28, 2018
1 parent 19e4b27 commit f67194a25ace6e10f64ee1d0ef49f62f74de28d2
Showing with 7 additions and 2 deletions.
  1. +5 −1 src/app/Api.js
  2. +2 −1 src/app/class/ItemsLoader.js
@@ -8,7 +8,7 @@ import Comment from './class/Comment';

class Api {
constructor() {
this.spreadsheetId = process.env.REACT_APP_SPREADSHEET_ID;
this.spreadsheetId = (new URL(window.location.href)).searchParams.get('id') || process.env.REACT_APP_SPREADSHEET_ID;
this.urls = {
// items: 'mock/items.json',
// categories: 'mock/categories.json',
@@ -53,7 +53,11 @@ class Api {
}).then((items) => {
SearchActions.changeItems(items);
window.items = items;
}).catch(() => {
SearchActions.changeItems([]);
});
}).catch(() => {
SearchActions.changeItems([]);
});
}
}
@@ -26,7 +26,7 @@ function json(url, Obj, decorator) {
items.push(new Obj(item));
});
resolve(items);
});
}).catch(e => reject(e));
});
}

@@ -40,6 +40,7 @@ function googleSpreadsheets(url, Obj, decorator) {
const script = document.createElement('script');
script.id = `spreadsheets_${random()}_${random()}_${random()}`;
script.src = url.replace('{1}', script.id);
script.onerror = e => reject(e);

if (document.getElementById(script.id) === null) {
window[script.id] = ((jsonData) => {

0 comments on commit f67194a

Please sign in to comment.