Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function doGet(request){
// Open Google Sheet using ID
var sheet = SpreadsheetApp.openById("1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk");
// Get all values in active sheet
var values = sheet.getActiveSheet().getDataRange().getValues();
var data = [];
// Iterate values in descending order
for (var i = values.length - 1; i >= 0; i--) {
// Get each row
var row = values[i];
// Create object
var feedback = {};
feedback['name'] = row[0];
feedback['email'] = row[1];
feedback['mobile_no'] = row[2];
feedback['feedback'] = row[3];
// Push each row object in data
data.push(feedback);
}
// Return result
return ContentService
.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment