kt-datatable component with axios
Hi good day how can we use kt-datatable component with axios in vuejs ? When we tried this its not updating the table data
setup() {
const tableHeader = ref([
{
key: "checkbox",
sortable: false,
},
{
name: "Name",
key: "Name",
sortable: true,
},
]);
let tableData = ref([]);
onMounted(async () => {
const { data } = await axios.get(API_URL_HERE, {
headers: {
'Authorization': this.token
}
tableData = data
})
});
return {
tableData,
tableHeader
};
},
Replies (3)
I am sorry, in your case there should be just a data instead of data.value.
tableData.value.splice(0, tableData.value.length, ... data); If this still will not work, please make sure that your data variable is not empty.
Also, check your console for errors.
Can you try the code example below?
tableData.value.splice(0, tableData.value.length, ... data.value); instead of
tableData = data