After making a GET request using Axios, I am successfully receiving data. However, I am facing an issue where I cannot access the application's data properties within the mounted function to store the results of the request. When I log this.productList
, it returns undefined
. Can someone help me troubleshoot this problem?
new Vue({
el: '#products',
data: function(){
return{
test: 'Hello',
productList: null
}
},
mounted: function(){
axios.get('https://api.coindesk.com/v1/bpi/currentprice.json').then(function(response){
console.log(response.data);
console.log(this.productList)
}).catch(function(error){
console.log(error);
})
}
})