Reputation: 658
I want to access the request_uuid
from my jquery post, but whatever I try doesn't work. I keep getting this error message:
Uncaught TypeError: Cannot read property 'request_uuid' of undefined
This is my array:
Array(
[status] => 201
[response] => Array
(
[api_id] => 6562c748-0366-11e5-84ff-22000ac89064
[message] => call fired
[request_uuid] => efa98dad-8869-4b72-ad99-a149f914bda5
))
I am trying to access it like this:
console.log(data.response['request_uuid']);
How should I access it to get the request_uuid
?
Upvotes: 1
Views: 1309
Reputation: 1845
If your data is an array and your response also, you must to parse the first child(0), before that:
[] = Array():
var data = [{
'status': 201,
'response': [{
'api_id': "6562c748-0366-11e5-84ff-22000ac89064",
'message': "call fired",
'request_uuid': "efa98dad-8869-4b72-ad99-a149f914bda5"
}]
}];
console.log(data[0].response[0]['request_uuid']);
Upvotes: 1