Submitting a post request through Vuejs and axios to a laravel back-end Submitting a post request through Vuejs and axios to a laravel back-end vue.js vue.js

Submitting a post request through Vuejs and axios to a laravel back-end


An improvement to the answer above would be to use Template Literals introduced in ES6.

Instead of:

axios.post('/MyCourses/' + course.name).then(console.log(course));

You can do:

axios.post(`/MyCourses/${course.name}`).then(console.log(course));

More information on Template Literals functionality and syntax can be found here:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals


The syntax you are using is wrong in following line:

axios.post('/MyCourses/{{course.name}}').then(console.log(course));

It should be :

 axios.post('/MyCourses/' + course.name).then(console.log(course));