1

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?

1
  • I would try something like var test = "testvalue"; and then data: test Commented Feb 8, 2016 at 13:46

1 Answer 1

1

Use $http.post method:

$http.post('/customer', { test: 'testvalue' }, {
    headers: {
        'Content-Type': 'application/json'
    }
}).then(function(){
    console.log("f1")
},function(){
    console.log("f2")
});
Sign up to request clarification or add additional context in comments.

1 Comment

This gives the same wrong output { '{"test":"testvalue"}': '' }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.