This is an old revision of the document!
Webex Connect JavaSscript Examples
Parse Google Sheets Example
Retrieve Google Sheets worksheet- example:
- https://sheets.googleapis.com/v4/spreadsheets/<google-spreadsheet-id>/values/<sheet-pagename>?key=<your-google-api-key>
Then set the response Code and Response Body as variables when leaving the HTTP node - as per below.
if (statusCode == 200) { const data = JSON.parse(responseBody); const inputArray = data["values"]; const headers = inputArray[0]; const rows = inputArray.slice(1); const output = []; for (let i = 0; i < rows.length; i++) { let rowObject = {}; // Create a new object for each row - note 'const' should work here - but didn't. Platform using old JS? for (let j = 0; j < headers.length; j++) { rowObject[headers[j]] = rows[i][j]; } output.push(rowObject); // Push the new object to the output array } myheaders = headers.toString(); myrows = rows.toString(); myoutput = output; customersJSON = JSON.stringify(output); 1; } else { 2; }