7 - Using Iterators in query results


#1

Hello, i'm trying to figuring out what is wrong with my code, here it is:

function iterateResults(){
var client = new Usergrid.Client({
//Initialize your client
orgName:"MyComp",
appName:"sandbox"
});

//Setup your options object here. Remember to put your book's 
//author in the query!
var options = {
    type:"book",
    qs: {"ql":"where author = 'Frank Herbert'"}
};

//Here is where we'll process the results of the query.
client.createCollection(options, function(error, books){
    while(books.hasNextEntity()) {
        //Put your call to .getNextEntity() below.
        var book = books.getNextEntity();
        //Get the book's title here!
        var title = book.get("title");
        $("#response").append("<li>"+title+"</li>");
    }

});

}

Can somebody help me?