I'm trying to send data to my NodeJS server with express.
The problem is that when I'm making the http post, the data gets wrapped in an object, where the data is the key in this object, and the value gets empty.
http({
method: 'POST',
url: '/api/booking',
data: {test:"data"},
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
}
}).then(function successCallback(response) {
console.log(response)
}, function errorCallback(response) {
console.log("API request failed: "+response);
});
the response will be like this;
{ '{"test":"data"}': '' }
I've tried a ton of different solutions which i have searched for. But I can't figure what the problem is.
I've also tried using postman, and in that case it works just fine.
Thanks!!
Problem not solved, but bypassed;
JSON.parse(Object.keys(req.body)[0]);
on serverside.