I am testing some code in my web console (using coffescript)
@user = new Onethingaday.Models.User()
@user.url= "/users/#{current_user.get('nickname')}.json?id_type=nickname"
@user.fetch()
console.log(@user)
console.log(@user.get("facebook_id"))
The console.log(@user) line shows the following:

However, console.log(@user.get("facebook_id")) shows undefined.
I see that user has the facebook_id attribute. How do I retrieve the value of it?
This looks like a timing issue, albeit an odd one.
fetchis asynchronous; you need to wait until itssuccesscallback is called before trying to access any attributes.Try this:
It’s confusing that the first
console.logwould showuser.attributes.facebook_idexisting and the second wouldn’t, butconsole.logis itself asynchronous in Webkit’s implementation, so what’s going on is that the@user.getcall is being resolved immediately (synchronously), whereas the object inspection in the firstconsole.logis resolving later—after thefetchcompleted.