Search code examples
javascriptnode.jsparse-platformparse-server

How to get a result of a Parse Server Query


How can I get the values of the searched objects?

const query = new Parse.Query(Parse.User);
      query.equalTo("sexo", "feminino");
      query
        .find()
        .then(results => {
          console.log(results.get("username"));
        })
        .catch(error => {
          console.log(error);
        });

TypeError: "results.get is not a function"


Solution

  • How to get values of a search query in Parse server ?

    Query.find will be able to fetch the results of your queries. As you can have multiples results, the object that you get is an array of elements

    so if you want to display the name of all users of your query you'll have to iterate to display all of your users.

    const query = new Parse.Query(Parse.User);
    query.equalTo("sexo", "feminino");
    query
        .find()
        .then(results => {
            results.forEach(user => {
                console.log(user.get("username"))
            });
        })
        .catch(error => {
            console.log(error);
        });
    

    If you want to have examples of queries click here

    Hope my answer help you 😊