I've to make a POST request to localhost:8080/api/session, sending email and password as x-www-form-urlencoded. In Postman, everything works, but trying two different solutions with Axios, I obtain 415-Unsopported Media Type
First solution:
var request_url = url + request.path;
var params = new URLSearchParams();
params.append('email', 'example@example.com');
params.append('password', 'example');
axios.post(request_url, params)
.then(res => {
console.log("ok")
})
.catch(error => {
console.error(error)
})
Second solution:
const data = qs.stringify({
email: 'example@example.com',
password: 'example',
});
const headers = {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
};
axios.post(
'http://10.10.0.145/api/session',
data,
headers
).then(result => {console.log("ok")});
What am I doing wrong?