Parse & JS: Return only one object

If you want exactly one result, a more convenient alternative may be to use first instead of using find.

<!doctype html>
<head>
    <title>My Parse App</title>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
    <script type='text/javascript' src='http://www.parsecdn.com/js/parse-1.2.17.min.js'></script>
</head>

<body>

<script>
    Parse.initialize('5d3sro43zBGj8AMYqWND5bFYMzAan7f5P5euZm7M', 'hlRZZqAylA7Fmah4Kk6ma8WK7QCT4cHrxjafnnkI');
    var MoviObject = Parse.Object.extend('MoviObject');
    var moviObject = new MoviObject();

    var query = new Parse.Query(MoviObject);

    query.first(
            {
                success: function (moviObject) {
                    document.write('<h2>First Movie Found:</h2>');
                    var title = moviObject.get('titleName');
                    document.write(title);
                }
            }
    );
</script>
</body>
</html>
Try The Code

As there is only one object, moviObject will not be in array form and so to get the title, we need only to use moviObject.get().

Series Navigation<< Parse & JS: Retrieving comment using the parentId
Parse & JS: Queries on String >>