I try a redirect after a post request is made, and I tried different things but nothing worked till now.
self.$router.push('/record')
Vue.$router.push('/record')
this.$router.push({ name: 'Record' })
Here is the updated code. with axios form component, app.js and main.js
axios.delete('/record/' + this.id)
.then((response) => {
this.$router.push('/record')
});
})
.catch(error => {
//
});
In my app.js
import VueRouter from "vue-router";
import router from "./router";
Vue.use(VueRouter);
new Vue({
router,
render: h => h(App)
}).$mount("#app");
router.js
import Vue from "vue";
import VueRouter from "vue-router";
import Record from './components/AddPerson';
Vue.use(VueRouter);
const routes = [
{
path: "/record",
name: "Record",
component: Record,
},
];
const router = new VueRouter({
mode: "history",
base: process.env.BASE_URL,
routes
});
export default router;
});underneath thepush- Dan