[Vuejs]-Can't change Vue Instance data values

1👍

Extremely common mistake. this defined in your FB.login callback is not the Vue. Use an arrow function, closure, or bind to make it correct.

FB.api('/me/accounts','get',{access_token: fb_token}, pages => {
  ...
})

See How to access the correct this inside a callback?

👤Bert

1👍

When you use this. in a callback it isn’t pointing to your Vue instance anymore. You can user => functions to bind this the way you want. Try this:

FB.api('/me/accounts','get',{access_token: fb_token},(pages) => {
        if(pages["error"] !== undefined){
           console.log('EROR')
        }
        else{
            console.log("Got a list of pages");
            console.log(pages);
           this.pages_fb = pages.data;
           this.showFb = false;
           this.showPages = true;
           this.continue_auth = true;
        }
   })
👤Mark

Leave a comment