tinthetub
tinthetub

Reputation: 2186

Parse, Fetch and Display ObjectID

Thanks to this previous thread: Parse, Fetch and Display Current User

I managed to display the Current User's username, I figured that I could also display the user's ID using .getObjectId();

So I gave that a try, but I get an error in the console telling me that it is undefined.

Here is my code:

$(document).ready(function(){ 

          Parse.initialize("xxxx", "xxxx");

         var currentUser = Parse.User.current(); 
         currentUser.fetch().then(function(fetchedUser){
                var name = fetchedUser.getUsername();
                var uniqueID = fetchedUser.getObjectId();
            $('.container').append('<ul class="nav pull-right"><li><a id="nametag" href="#">' + name + '</a></li></ul>');
            $('.btn-box-row row-fluid').append('<a href="#" class="btn-box big span4"><i class=" icon-random"></i><b>' + uniqueID + '</b>');
            });
         });

Upvotes: 0

Views: 102

Answers (1)

Luca Iaco
Luca Iaco

Reputation: 3457

Try with fetchedUser.id

Hope it helps

Upvotes: 1

Related Questions