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
}
});
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
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.