title: Parse .then method and chaining | Syntax eludes me
body: <p>Dear stackoverflow community,</p>
  
  <p>I am using application craft as a JS cloud IDE and integrating Parse's cloud database for storage.</p>
  
  <p>I'm writing a subscription service and want to check to see if a user is already subscribed prior to either authenticating their use or prompting them to sign up. Being an asynchronous call I'm trying to utilise Parse's/Promise's <a href="https://parse.com/docs/js_guide#promises-then" rel="nofollow">.then method</a> to wait for the server's response before proceeding.</p>
  
  <p>I've read the examples and samples on the Parse site (linked before) yet cannot wrap my head around it.</p>
  
  <p>This code functions, and returns the email address if a match is found:</p>
  
  <pre><code>      ... *Parse declaration etc*  
  query.find({
              success: function(results){
                  if(results.length&gt;0){
                      app.setValue("lblOutput", results[0].attributes.email);
                  }
                  else{
                      app.setValue("lblOutput", "No match.");
                  }
              },
              error: function(object, error){
                  console.log(error.message);
                  console.log(object);
              }
          });  
  </code></pre>
  
  <p>My attempt at chaining, most recently this:</p>
  
  <pre><code>    query.find().then(function(results) {
          if(results){
              console.log("Within the Then!");
              console.log(results);
          }
          else{
              console.log("Could be an error");
          }
      });
  </code></pre>
  
  <p>States that method or property 'success' is invalid for undefined. I have attempted to combine the syntax of the first function (success: ... // error: ...) in the chaining attempt unsuccessfully.</p>
  
  <p>Any advice as to how I could</p>
  
  <ol>
  <li>Check to see if an email exists in the Parse DB, <strong>then</strong></li>
  <li>Wait until the result comes back for further manipulation with another function</li>
  </ol>
  
  <p>would be greatly appreciated.</p>
  
  <p>Once I have .then() figured out there will be further layers of async waiting.</p>
  
  <p>Cheers,</p>
  
  <p>James</p>