javascript - Parse .then method and chaining | Syntax eludes me -


Dear Stack Overflue Community,

I am using application craft in the form of the JS Cloud IDE and am integrating the pars' cloud database.

I am writing a subscription service and want to check to see if a user has already subscribed before motivating them to authenticate or sign up their use. Being asynchronous call, I pars / promise that before the proceeding I am waiting for the server's response.

I have read examples and samples on a parse site (previously added) so far can not wrap my head

  ... * parse announcement etc. * query Find {{success:  

work (results) {if (results.length> gt; {app.setValue ("lblOutput", results [0] .attributes.email);} other {app} .setValue ("lblOutput", "no matching.");}}, Error: function (object, error) {console.log (error.message); console.log (object);}});

My attempt at Chenning, recently it:

  query.find (). Then (function) {if (result) {console log in ("inside!"); Console.log (result);} else {console.log ("may be an error");}});  

States that the law or property is' invalid for 'undefined' success, I have tried to combine the syntax of the first function (success: ... // error: ...) , Because Chenning failed in an attempt.

How do I

ol>
  • Whether an email exists in Pars DB, then
  • Wait until the result for further manipulation with any other function will not return
  • will be highly appreciated.

    Once I have Then () will be detected that async is waiting and the layers are.

    Cheers,

    Z

    Your syntax is incorrect, it should be:

      query.find (). Then (function (result) {console.log ("then within!"); Console.log (result);}, function (error) {console.log ("may be an error" + error);}) ;  

    Then () function takes one or two functions.

    The first breakthrough is the handler, and the other is the error handler.

      var query = new parse.Query (pars.) User); Query.equalTo (email, "me@me.com"); ("Error:" +++) If you (ifCount> gt; 0) {doSomeOtherFunction ();}}, function (error) {// error handler console.log} error);});  

    If you have more async work to do, then your method should look like this, remember that when the promise of a chain is done, then finally your error handling should be ().

      query.find (). Then (work (result) {doSomethingAsync (); // requires a promise back to the chain to work!}). Then (function (result 1) {doSomethingAsync2 (); // a promise for the chain to work!}). Then (function (result 2) {doSomethingAsync3 (); // requires a promise for the chain to work again!}). Then (zero, function (error) {// handles errors in an alternate way / handle errors for all incremental promises.})  

    Comments

    Popular posts from this blog

    java - org.apache.http.ProtocolException: Target host is not specified -

    java - Gradle dependencies: compile project by relative path -

    ruby on rails - Object doesn't support #inspect when used with .include -