0👍
The headers object should not be put into a "config" object.
It’s just…
axios({
method: 'post',
url: urltocall,
{
headers: {
....
- [Vuejs]-Issue data-binding in conditional rendering (Vue.js)
- [Vuejs]-MEVN app deployment to Heroku failed because of 'vue-cli-service' not found
0👍
Try doing it like this:
axios
.post(urltocall, myDataAsJSON, {
headers: {
"Access-Control-Allow-Origin": "http://localhost:1337",
"Accept": "application/json",
"Content-Type": "application/json",
"username": "test1"
}
})
.then(response => {
console.log("Success: " + response.data);
})
.catch(error => {
console.log("Error: " + error.response.data);
});
By the way, based on your 'Content-Type': 'application/json',
, I know you’re trying to send a JSON object, but where/what is this object?
Also, refer to the Full documentation for more information.
Source:stackexchange.com