Anand Jain
Anand Jain

Reputation: 819

How to get object array value from response array

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?

Upvotes: 0

Views: 1407

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136184

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']);

Upvotes: 1

Related Questions