I'm still learning this VueJS with Laravel, what I want to do is to get the categories data from API and load it into the select dropdown, but I found that this Axios request running too long.
here's the snippet code
export default {
data() {
return {
category: 0,
categories: [],
loading: true,
}
},
async created() {
let uri = '/api/getCategory';
axios.get(uri).then(response => {
this.categories = response.data;
console.log('2');
}).catch(error => console.log(error))
.finally(() => {
this.loading = false;
});
console.log('1');
},
methods: {
loadCategories() {
axios.get('/api/getCategory')
.then(response => this.categories = response.data)
.catch(error => console.log(error));
}
}
}
based on this. 1 DOM LOADED 2
is there a way to make my Axios API request to fetch the data first before the HTML finish loaded?
beforeMount()hook?