GoogleSheet as backend

Hi all,

Has anyone managed to connect GoogleSheet to AppGyver without any third app?
So far, i have set my Sheet as a Rest API with this code:

function json(sheetName) {
  const spreadsheet = SpreadsheetApp.getActiveSpreadsheet()
  const sheet = spreadsheet.getSheetByName(sheetName)
  const data = sheet.getDataRange().getValues()
  const jsonData = convertToJson(data)
  return ContentService
        .createTextOutput(JSON.stringify(jsonData))
        .setMimeType(ContentService.MimeType.JSON)
}

function convertToJson(data) {
  const headers = data[0]
  const raw_data = data.slice(1,)
  let json = []
  raw_data.forEach(d => {
      let object = {}
      for (let i = 0; i < headers.length; i++) {
        object[headers[i]] = d[i]
      }
      json.push(object)
  });
  return json
}

function doGet(e) {
  const path = e.parameter.path
  return json(path)
}

However, when I try to connect it to AppGyver with:

  • Resource URL: Google Drive: Sign-in
  • GET relative path: my Sheet ID
  • GET response key path: my sheet name

And the test result is:
Error: TypeError: Failed to fetch. Does the server allow CORS?status :undefined

Any idea???

Many thanks.

Matt

you are very brave, man