What's the equivalent axios code for this:
<form method='post' action='https://sample.com' enctype='multipart/form-data'>
I tried the following
const bodyFormData = new FormData();
bodyFormData.set('name', inputData.name);
bodyFormData.set('hush_sender', inputData.email);
bodyFormData.set('subject', inputData.subject);
bodyFormData.set('message', inputData.message);
const response = await axios({
method: 'post',
url: `https://sample.com`,
data: bodyFormData,
config: {
headers: {
'Content-Type': 'multipart/form-data',
enctype: 'multipart/form-data'
}
}
});
But I get the following error when using axios:
Access to XMLHttpRequest at 'https://sample.com' from origin 'http://localhost:3001' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
(I don't have control over mydomain.com. That is a third party api. They sent the code in the html form, but I want to use axios.)