-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
31 lines (23 loc) · 865 Bytes
/
data.js
File metadata and controls
31 lines (23 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// data-fetcher.js
// Handles fetching JSON data from Google Sheets
async function fetchGoogleSheetData() {
const url = `https://opensheet.elk.sh/1Zl8GQiawIi8IIIpnwfOiGXmCjGpRiYvKGEesk8gPMUA/Form Responses 1`;
try {
console.log('Fetching from:', url);
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error: ${response.status} - Make sure the Sheet is publicly shared`);
}
const data = await response.json();
// Filter out rows where all fields are empty
const dataRows = data.filter(obj =>
Object.values(obj).some(val => val && val.toString().trim() !== '')
);
console.log('Sheet data loaded:', dataRows);
return dataRows;
} catch (error) {
console.error('Error fetching Google Sheet:', error);
return [];
}
}
export { fetchGoogleSheetData };