Created
March 25, 2022 15:42
-
-
Save ChaiyachetU/2e1529a7fd6e88804222f7ac026ad6a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
const ssURL = "ํYour Google Sheet URL"; | |
const ss = SpreadsheetApp.openByUrl(ssURL); | |
let response = []; | |
const sheetName = e.parameter.sheet; | |
if (sheetName === "address") { | |
const sheet = ss.getSheetByName(sheetName); | |
const address = sheet.getDataRange().getValues(); | |
address.forEach((address, index) => { | |
if (index !== 0) { | |
response.push({id: index, province: address[0], district: address[1], subdistrict: address[2], postcode: address[3] }); | |
} | |
}) | |
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON); | |
} else { | |
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment