title: How do I get Gmail API to list messages in Javascript?
body: <p>I used listMessages to get the Id and getMessages to print the snippet, however it doesn't seem to work:</p>
  
  <pre><code>      function listMessages() {
      gapi.client.gmail.users.messages.list({
        'maxResults': 1000,
        'userId': 'me',
        'format': 'full',
  
      }).then(function(response) {
        appendPre('Files:');
        var messages = response.result.messages;
        if (messages &amp;&amp; messages.length &gt; 0) {
          for (var i = 0; i &lt; messages.length; i++) {
            var message = messages[i];
            var message_Id = message.id;
            window.message_Id = message_Id;
            getMessages();
  
          }
        } else {
          appendPre('No files found.');
        }
      });
    }
    function getMessages() {
      gapi.client.gmail.users.messages.get({
        'maxResults': 1000,
  
        'id': message_Id,
        'userId': 'me',
        'format': 'full',
  
      }).then(function(response) {
  
        var messages = response.result.messages;
        if (messages &amp;&amp; messages.length &gt; 0) {
          for (var i = 0; i &lt; messages.length; i++) {
            var message = messages[i];
  
            appendPre(message.threadId + ' (' + message.snippet + ')');
          }
         else {
          appendPre('No files found.');
  
        }
      });
    }
  </code></pre>
  
  <p>For some reason it only returns with no files found, how can I get it to print out the snippet and Id?</p>