An ajax request (stored in a variable named results
) is returning this data as a response:
Object {hits: Object, links: Object}
hits:Object
hits:Array(2)
0:Object
active:true
email:"user1@example.com"
id:1
links:Object
__proto__:Object
1:Object
active:true
email:"user2@example.com"
id:2
links:Object
__proto__:Object
length:2
__proto__:Array(0)
total:2
__proto__:Object
links:Object
__proto__:Object
What sort of data type it has? I thought it is json but using JSON.parse(results)
returns this error:
Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
How can I get access to the Array inside it? I need to get the email addresses and ids. It's probably not relevant but I'm using it in a ReactJS component.