Accessing property of this object

I can't fathom what I am missing here, I need extra eyes on this please. I want to access the "fileUrl" property of this response object.


I tried this two and none worked

 1. contentImageUrl = response.response.fileUrl;
 2. contentImageUrl = response.fileUrl;

both returned undefined. What are my missing?

1 answer

  • answered 2017-06-17 18:15 meagar

    response.response is itself a nested JSON document. It has somehow been double-JSON encoded. This might be intentional (it's the "main" portion of the response, while the other properties are meta data about the response) or it may be accidental, but regardless you need to parse it before you can access properties of the nested object:

    contentImageUrl = JSON.parse(response.response).fileUrl;