0

I have a parse.com database which i am querying using the objectID. It returns the data but I can only see it inside the promise object as an attribute, i can't figure out how this works from the documentation, how should i actually get the data and turn it into an object rather than a Promise. Should i call the function after or save it as a variable or something in the success function, do i need to define review somewhere earlier? any example would be awesome

        var query = new Parse.Query("business_and_reviews");
        var results = new Parse.Object("business_and_reviews");
        query.get("pLaARFh2gD", {
            success: function(results) {
                // results is an array of Parse.Object.
            },
            error: function(object, error) {
                // The object was not retrieved successfully.
                // error is a Parse.Error with an error code and message.
            }
        });
        var name = results.get("city");
        console.log(name);

This is the Promise in chrome

chrome console

2 Answers 2

1

get() returns only one object with the id.

var query = new Parse.Query("business_and_reviews");
query.get("pLaARFh2gD", {
    success: function(result) {
        var name = result.get("city");
        console.log(name);
    }
});

Here is another example from the document.

var GameScore = Parse.Object.extend("GameScore");
var query = new Parse.Query(GameScore);
query.get("xWMyZ4YEGZ", {
    success: function(gameScore) {
        var score = gameScore.get("score");
        var playerName = gameScore.get("playerName");
        var cheatMode = gameScore.get("cheatMode");
    },
    error: function(object, error) {
        // The object was not retrieved successfully.
        // error is a Parse.Error with an error code and message.
    }
});
Sign up to request clarification or add additional context in comments.

Comments

0

Thanks, I solved it now, first had to be inside the success: function, then had to select the info in the object as follows:

        var query = new Parse.Query("business_and_reviews");
        var results = new Parse.Object("business_and_reviews");

        query.get("pLaARFh2gD", {
            success: function(results) {

                console.log(results["attributes"]["city"]);

                },
            error: function(object, error) {
            }
        });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.