Stuck at Chapter 19


#1

Hello,
I am stuck at Chapter 19 - Adding Users to a group. When I click on "Save & Submit Code", all I can see is "Waiting for an unknown event". Then, when I go back to the Editor, it gives me the following error:

Oops, try again. Please follow the instructions on the Full Preview page to test your code.

function addUserToGroup(){
var client = new Usergrid.Client({
//Intialize your client with the proper credentials
orgName:"xyz",
appName:"sandbox"
});

//fill out the group options here!
var options = {
    client: client, 
    path:"explorers"
};

var explorers = new Usergrid.Group(options);
explorers.fetch(function(error, data){
    client.login("user1234", "1234", function(error, data, loggedInUser){
        //Use the explorers object to add the user entity to the group.
        //Set the user property of options to the user entity
        //in the callback above

        var options = {
            //Set this to the value of the logged in user
            user:"user1234"  
        };

        explorers.add(options, function(error, data, list){
            //Use the members helper to get all the members of a group!
            explorers.members(function(err, members){
                //Get the first member of the group
                var member = members[0];
                //Get the username of the first group member here
                var username = member.get("username");
                //Use the get() function to get the user's name
                $("#response").html(username);               
            });
        });

    });
});

}

Please help.
Thanks


#2

You need to set it to loggedInUser not user you want to set it to.

It states you need to set it to first member of the group. there are no members in program,they are all users so replace member with user. also you need to get first user in group see the line before :

place 0 in normal brackets and there you go.
var username = user.get(0)