Apigee 19/21


#1

I have no idea what's wrong with my code..

function addUserToGroup(){
var client = new Usergrid.Client({
//Intialize your client with the proper credentials
orgName:"driesmeyers",
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("driesmeyers", "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: loggedInUser 
    };

    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 = loggedInUser.get("username");
            //Use the get() function to get the user's name
            $("#response").html(username);               
        });
    });

});

});
}


#2

you are fetching normal users so no need for loggedInUser comand. also you need the first user in group. ssee what they did wit line before members[0], replace "username" with 0 as the first value in group.