Send form data with axios (Vue.js)

Send form data with axios (Vue.js)

Sending JSON is the default for axios and doesn't need to be mentioned. When I've implemented a JWT login (which needed form data to be send), I thought it will just need a special header. But no.

There is a special class called FormData which can be send as data and you're automatically sending your request as form data.

For example:

const formData = new FormData();
formData.append('_username', email);
formData.append('_password', password);

  .post('/api/login', formData)
  .then(response => {