Solution: Axios Post Form Data in VueJS

Author: Zeeshan Arshad     776     05/14/2018

Estimated reading time: 0 minutes, 14 seconds

By default axios sends JSON data and if you receive POST data on PHP you need to configure the header as urlencoded:

Here is how you can do it in Vue.

var config = {
  headers: {
  'Content-Type': 'application/x-www-form-urlencoded',
}
};

axios.post('ajax.php', {
  parameter: value
})
.then(function (response) {
  // your data
}, config);

Was this topic helpful?

Yes
No
Subscribe YouTube Channel

Zeeshan Arshad is a multipotentialite web developer who also happens to know about growth hacking, blogging, closing, marketing, copywriting, spirituality, virtual reality and more. Zeeshan is a Freelancer Top Contributor, vWorker Top Coder and Udemy Premium Instructor.

Story  LinkedIn Profile  Courses  YouTube