I encountered an issue with the following code snippet inside my ready method:
this.$http.get('url',{},{
headers: {
"X-App-Token": "token"
}
}).then( (data) => this.$set('cdata',data.data))
.catch( (error) => console.log('Got a problem'+error));
While this code works fine in the ready method, when I attempt to move it to another function within the methods object, it fails to work.
ready(){
this.getJsonData();
},
methods: {
getJsonData: () => {
this.$http.get('url',{},{
headers: {
"X-App-Token": "token"
}
}).then( (data) => this.$set('cdata',data.data))
.catch( (error) => console.log('Got a problem'+error));
},
},
The error message reads:
src\src\App.vue:23 Uncaught TypeError: Cannot read property '$http' of undefined
//this becomes undefined.