I try to post an object with axios. I need it to be in a format like this:
var dataObj = {username:"username",password:"password",data1:"data1"};
When i POST it with axios and catch in the backend, it adds an extra key to the object like this:
{dataObj:{username:"username",password:"password",data1:"data1"}};
How can i get rid of this extra field before sending it to backend so it will look like this?
{username:"username",password:"password",data1:"data1"}
I know i can parse it in the backend but i cant modify the backend cuz its not mine.
This is how my axios post looks like:
axios.post('http://192.168.1.1xx:3000/data', {
dataObj
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Thanks :)
Instead of :
Remove brackets ↪ i mean
,dataObj)
instead of, {dataObj})
... because "dataObj" is already a literal object.