Wednesday, 9 January 2019

Posting to axios directly from a form

Im trying to post to axios using a form.. Google is returning no results. Help please?var testForm = document.getElementById('test-form'); testForm.onsubmit = function(event) { event.preventDefault(); var request = new XMLHttpRequest(); var data = new FormData(document.getElementById('test-form')); axios({ method: 'post', url: '/patients', data: data, config: { headers: {'Content-Type': 'multipart/form-data' }} }) .then(function (response) { console.log(response); console.log(data); }) .catch(function (error) { console.log(error); }); } Currently its not submitting the data properly and gives a status:200 with an error on the data.

Submitted January 09, 2019 at 11:36PM by myope-uk

No comments:

Post a Comment