title: How to use Google sheets API while inside a google cloud function
body: <p>I'm trying out Google's Cloud Functions service and I want to read and write a Google Spreadsheets but can't seem to find any examples or ways to do this. </p>
  
  <p>My problem steams from the fact that the example javascript for a Google cloud function is:</p>
  
  <pre><code>exports.helloWorld = function helloWorld (req, res) {
    res.send(`Hello ${req.body.name || 'World'}!`);
  };
  </code></pre>
  
  <p>This works but I want to do what google has as a example to read from a Google spreadsheet:</p>
  
  <pre><code>  gapi.load('client:auth2', initClient);
  
    function initClient() {
      gapi.client.init({
        discoveryDocs: DISCOVERY_DOCS,
        clientId: CLIENT_ID,
        scope: SCOPES
      }).then(function () {
        // Listen for sign-in state changes.
        gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
  
        // Handle the initial sign-in state.
                gapi.client.sheets.spreadsheets.values.get({
        spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
        range: 'Class Data!A2:E',
      }).then(function(response) {
        var range = response.result;
        if (range.values.length &gt; 0) {
          appendPre('Name, Major:');
          for (i = 0; i &lt; range.values.length; i++) {
            var row = range.values[i];
            // Print columns A and E, which correspond to indices 0 and 4.
            appendPre(row[0] + ', ' + row[4]);
          }
        } else {
          appendPre('No data found.');
        }
      }, function(response) {
        appendPre('Error: ' + response.result.error.message);
      });
      });
    }
  </code></pre>
  
  <p>Does anyone know if this is possible or an example that shows how to do something similar to this?</p>