Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How to reload the data of a table with vue and axios?

$
0
0

Link to test case:
I want to refresh the table data after inserting my code is like below it does not load the data until I refresh it

```

         table() {    this.$nextTick(() => {
                    $('#sampleTable').DataTable();
                   })
                   },
                 get() {
                   axios.get('api/user').then(res => {
                    this.users = res.data
                    // console.log("after: " + this.users);
                    this.table()
                    });
                 axios.get("api/getRoles").then(({
                       data
                    }) => (this.roles = data));
                    // if (refreshIt == true) {

                        // this.retable();
                    // } else {

                       this.table();

                    // }

                $(".selectpicker").selectpicker();
            },
              create() {
                                // this.validation();
                this.form.post('api/user').then(() => {
                        $("#addnew").modal("hide");
                        toast.fire({
                            icon: "success",
                            type: "success",
                            title: "Information Created Successfully!"
                        });
                         Fire.$emit("refreshPage");
                        this.form.reset();

                    })
                    .catch(er => {
                        console.log(er);
                    });
             created() {
            // we call the show function here to be executed
                    this.get();

            Fire.$on("refreshPage", () => {

              this.get();


        });}
                   

Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:


Viewing all articles
Browse latest Browse all 2364