Reputation: 557
response._bodyText
works, but I get undefined when I use response._bodyText.result
Upvotes: 0
Views: 164
Reputation: 1109
First you have to parse that because its in json format. Try
data = JSON.parse(response._bodyText)
data.result
For Reference you can study about JSON
Upvotes: 1
Reputation:
response._bodyText.result
is undefined
because _bodyText
is a string.
You must first turn _bodyText
into an object:
var body = JSON.parse(response._bodyText);
After that body.result
should work.
Upvotes: 0
Reputation: 1840
What you have inside response._bodyText
is a stringified JSON.
To access the keys inside of it. you need to first parse it using JSON.parse
Example: JSON.parse('{ "hello":"world" }')
This will give you an object {hello: 'world'}
In your case you do JSON.parse upon response._bodyText
, then you can access it just like a normal object.
JSON.parse(response._bodyText)
Upvotes: 0
Reputation: 1674
you need to parse it
try
JSON.parse(response._bodyText).result
Upvotes: 0