Search code examples
javascriptparse-server

Parse-Server: Unable to query objects


at the top of my index.html, I successfully initialize Parse-Server like this:

<script>
    Parse.initialize("MY_KEY");
    Parse.serverURL = 'http://MY_APP_NAME.herokuapp.com/parse/';
    /*var GameScore = Parse.Object.extend("Test");
    var gameScore = new GameScore();
    gameScore.save({playerName: "Granto"}).then(function(object) {
        alert("SUCCESS BRAHSKI");
    });*/
</script>

I know the initialization is successful because I'm able to save a Test Object into the server as shown in the commented code above.

However, When I try and query objects from my server, Nothing happens. What is wrong with my query?

var query = new Parse.Query("Test");  
    query.find({
        success: function (results) {
        alert("Query SUCCESS");
    },
    error: function (error) {
        alert("Query Error:" + error);
    }
});

Solution

  • Correct Syntax for a Parse-Server Query:

    var query = new Parse.Query("Client");
    
    query.find()
      .then(function(results) {
       alert("SUCCESS");
    })
      .catch(function(error) {
       alert("ERROR");
    });