1

Using parse.com and the JavaScript SDK, I want to create a query that checks if a user is already existing.

There is example code here, which I've adopted and turned into the below code block. I'm getting an Uncaught ReferenceError: username is not defined error, which I don't understand why?

https://www.parse.com/docs/js_guide#users

var friendFinder = Parse.Object.extend("_User");
var query = new Parse.Query(Parse.User);
query.equalTo(username, "d"); // find users that match
query.find({
    success: function (friend) {
        if (friendName.length) {
            console.log("Success")
        }
    },
    error: function (error) {
        //Show if no user was found to match


    }
});

1 Answer 1

1

You forgot quotes on the "username" field:

var friendFinder = Parse.Object.extend("_User");
var query = new Parse.Query(Parse.User);
query.equalTo("username", "d"); // find users that match
query.find({
    success: function (friend) {
        if (friendName.length) {
            console.log("Success")
        }
    },
    error: function (error) {
        //Show if no user was found to match


    }
});
Sign up to request clarification or add additional context in comments.

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.