0

I've defined this.username already; however, when being inside a function it get undefined how can I retrieve its value?

 Parse.User.logIn(this.username, this.password, {
   success: function(user) {

       //gets undefined
       console.log('username is : ', this.username);

    }});
Folky.H
  • 1,164
  • 4
  • 15
  • 37

1 Answers1

1

it's because that callback has a different scope compared to the outer function.

save a reference of this outside the function

var self = this;

then use self inside the function.

Karim
  • 8,454
  • 3
  • 25
  • 33