javascript - Post method in Angular JS -


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 need this:

{"test":"testvalue"}

does 1 know solution problem?

use $http.post method:

$http.post('/customer', { test: 'testvalue' }, {     headers: {         'content-type': 'application/json'     } }).then(function(){     console.log("f1") },function(){     console.log("f2") }); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -