6/21 what am i doing wrong?


#1

I did exactly what the instructions said and it still doesn't run. What is wrong with my code.

function queryAppServices(){
var client = new Usergrid.Client({
orgName:"nathan",
appName:"sandbox"
});

//Here is the name of your book
var title ="Dune";

//Setup the query options object
var options = {
  type: "books",
  qs : {"ql": "where title = '"+title+"'"}
};

//Create collection will give back a collection of objects that
//conform to your query.
client.createCollection(options, function(error, books){
    if(error) {
        $("#response").append("Error");
    } else {
        //Get the first entity of the collection here.
        var firstBook = books.getFirstEntity();
        //Use the get() function to get the title of your book here
        var title = firstBook.get("title");
        //Use the get() function to get the uuid of your book here
        var uuid = firstBook.get("uuid");
        $("#response").append("Your book title is:"+title+" it's uuid is:"+uuid);
    }
});

}


#2

I've been stuck on this for ages, finally got it to work. I didn't even enter in the full correct code but it worked to my surprise. Here is my code:

function queryAppServices(){
    var client = new Usergrid.Client({
        orgName:"nathan",
        appName:"sandbox"
    });
    
    //Here is the name of your book
    var title ="Dune";
    
    //Setup the query options object
    var options = {
      type: "book",
      qs : {"ql": "where title = '"+title+"'"}
    };
    
    //Create collection will give back a collection of objects that
    //conform to your query.
    client.createCollection(options, function(error, books){
        if(error) {
            $("#response").append("Error");
        } else {
            //Get the first entity of the collection here.
            var firstBook = books.getFirstEntity()
            //Use the get() function to get the title of your book here
            var title = firstBook
            //Use the get() function to get the uuid of your book here
            var uuid = firstBook
            $("#response").append("Your book title is:"+title+" it's uuid is:"+uuid);
        }
    });
}

#3

thanks you're the best. :lemon: :eggplant: :grin:


#4

I am having the same problem. I tried your code above, that did not work. I also changed line 25 and line 27 accordingly. Can't get it to work either.

function queryAppServices(){
var client = new Usergrid.Client({
orgName:"John",
appName:"sandbox"
});

//Here is the name of your book
var title ="Dune";

//Setup the query options object
var options = {
  type: "book",
  qs : {"ql": "where title = '"+title+"'"}
};

//Create collection will give back a collection of objects that
//conform to your query.
client.createCollection(options, function(error, books){
    if(error) {
        $("#response").append("Error");
    } else {
        //Get the first entity of the collection here.
        var firstBook = books.getFirstEntity()
        //Use the get() function to get the title of your book here
        var title = firstBook.get("title")
        //Use the get() function to get the uuid of your book here
        var uuid = firstBook.get("uuid")
        $("#response").append("Your book title is:"+title+" it's uuid is:"+uuid);
    }
});

}


#5

Hi I'm Josh,

Given the above and that my own browser doesn't display any results whatsoever, I think this lesson is broken.