forked from mstamenk/us-cms-lpc-alumni-prototype
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.gs
More file actions
25 lines (22 loc) · 730 Bytes
/
Copy pathCode.gs
File metadata and controls
25 lines (22 loc) · 730 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
const SHEET_NAME = 'Form Responses 1';
function doGet(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME);
const [headers, ...rows] = sheet.getDataRange().getValues();
const data = rows
.filter(row => row.some(cell => cell !== ''))
.map(row => {
const obj = {};
headers.forEach((h, i) => { obj[h] = row[i]; });
return obj;
});
const json = JSON.stringify(data);
const callback = e.parameter.callback;
if (callback) {
return ContentService
.createTextOutput(`${callback}(${json})`)
.setMimeType(ContentService.MimeType.JAVASCRIPT);
}
return ContentService
.createTextOutput(json)
.setMimeType(ContentService.MimeType.JSON);
}