I'm trying to make a simple post call that will send data to mailgrid so an automatic mail will be send to the chosen person. But as i'm relative new to making API calls in general there are some thing I don't understand.
These are the errors I get when i try to make the call:
header ‘content-type’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response
And
CORS request did not succeed
He is my function that executes the call:
const sendMail = () => {
axios.post(`https://{{private_url}}/public/mail/{user_id}/{mail_id}`, {
headers: {
"Access-Control-Allow-Headers": "Content-Type",
},
data: {
first_name: data.first_name,
last_name: data.last_name,
message: data.message,
email: data.email,
}
})
.then(response => {
console.log(response);
console.log(response.headers)
close();
})
.catch(error => {
console.log(error);
console.log(error.headers)
});;
}
What am I overseeing or where am I making a mistake ?