[Vuejs]-Vue form axios post not submitting

1👍

You’re calling this.formdata instead of this.formData?
Edit:
notice: you’re using

onSubmit: function () {}

Don’t use the normal function since this here refers to the current function
use ES6 function

onSubmit() {}

Edit:

var form = new FormData()

form.append('name', this.formData.name)
form.append('email', this.formData.email)
form.append('deptid', this.formData.deptid)
form.append('message', this.formData.message)

  axios.post("https://hostedcarbon.com/backend/contact.php", form)
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.error(err);
  });

Leave a comment