Answer the question
In order to leave comments, you need to log in
Am I making asynchronous requests right?
Tell me if I'm doing it right, it seems to me that the code is repeated and you can somehow write it differently
created(){
setTimeout(() => {
let employeeApi = new restApi(this.$props.data_table);
employeeApi.list().then(res => {
this.items = res.data;
});
});
setTimeout(() => {
let employeeColumn = new restApi(this.$props.data_columns);
employeeColumn.list().then(res => {
this.columns = res.data;
})
});
}
Answer the question
In order to leave comments, you need to log in
You need something like this:
let employeeApi = new restApi(this.$props.data_table);
let employeeColumn = new restApi(this.$props.data_columns);
let arr = [employeeApi.list(), employeeColumn.list()];
Promise.All(arr).then(res=> {
this.items = res[0].data;
this.columns = res[1].data;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question