Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
};
},


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi @Lauris thanks for your response but that doesnt seem to work



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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(