I am working on a laravel project with vue components. When i do a get request with axios in my component i cant set the data variable to the response. these are my methods:
methods: {
location ()
{
console.log('location')
},
getCategories () {
axios.get(this.baseUrl + '/api/search/categories').then((response) => {
this.categories = response.data
console.log(response.data)
}).catch((e) => {
console.log(e)
})
}
}
Here is my data()
data() {
return {
searchTitle: null,
searchLocatie: null,
searchCategorie: null,
categories: [],
//baseUrl: 'https://sdinbeeld.frb.io/',
baseUrl: 'http://localhost:8888/sdinbeeld/public/'
};
},
I want to set this.categories
equal to response.data
but when i do console.log(this.categories)
in the mounted()
section it returns just an empty array
Does someone know ho to fix this?