Reputation: 43
I have following code:
var req = {
method: 'POST',
url: '/customer',
headers: {
'Content-Type': 'application/json'
},
data: { test: 'testvalue' }
};
$http(req).then(function(){
console.log("f1")
},function(){
console.log("f2")
});
The code above posts this:
{ '{"test":"testvalue"}': '' }
When I need something like this:
{"test":"testvalue"}
Does any one know the solution to this problem?
Upvotes: 1
Views: 50
Reputation: 4738
Use $http.post
method:
$http.post('/customer', { test: 'testvalue' }, {
headers: {
'Content-Type': 'application/json'
}
}).then(function(){
console.log("f1")
},function(){
console.log("f2")
});
Upvotes: 1