jeudi 27 août 2015

How to get a Backbone Model attribute after fetch?

I know that a fetch is asynchronous and it needs to use "success" in fetch. But what if I want to use the data out of the success? I wanna to get the user ID and to use it in a model "Note".

 authedUser.fetch({
            success: function(){;
                window.uid = authedUser.get("id");
            }

But if I try to do this console.log(uid); not in success I get undefined.




Aucun commentaire:

Enregistrer un commentaire