0

How to get object array value from response array? Below is my code to send Ajax request

var post_data = {
    "user_name_title" : $scope.user_name_title,
};
$http.post(url,post_data).then(function(res)
{
    console.log(res['Message']);
},

Output is

{
  "ResponseCode": 200,
  "Data": [],
  "Message": "Data inserted successfully.",
  "Error": []
}

How can I get the result objects, I have used

console.log(res['Message']);

but it showing undefined. What should I use?

2
  • That looks like it should work, can you post a demo to reproduce the issue? Commented May 31, 2016 at 11:20
  • Error - Unexpected token o in JSON at position 1 at Object.parse (native) Commented May 31, 2016 at 11:22

1 Answer 1

1

As you are using .then over $http method, you should get API response data inside data property of response object, like below.

console.log(res.data['Message']);
Sign up to request clarification or add additional context in comments.

Comments

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.