loopback icon indicating copy to clipboard operation
loopback copied to clipboard

how to access the JSON object in IONIC ??

Open Banda17 opened this issue 7 years ago • 3 comments

want to access the Photo attribute from the JSON Object, I am new to Angular and Loopback, I have been trying for Hours but I am not able to access that photo attribute.

Here is the JSON object I am getting from the Server

__zone_symbol__state: true ​ __zone_symbol__value: {…} ​​ Photo: "http://192.168.1.11:3000/api/Pictures/images/download/1559895053710.jpg" ​​ email: "[email protected]" ​​ emailVerified: false ​​ mobileno: "9490100101" ​​ name: "Testuser" ​​ societyId: "5ca71e45af5f770e103cff5a" ​​ username: "Test1"

And Here is the method I am using to access the attribute as in loopback page I have read that they can be accessed by using just '.'

var k = this.auth.profiledata(); console.log(k.Photo);

The actual output should be this "http://192.168.1.11:3000/api/Pictures/images/download/1559895053710.jpg" when printing the K value but I am getting undefined.

when I stringify the output i am getting this Object { __zone_symbol__state: null, __zone_symbol__value: [] }

instead of the JSON Object

Banda17 avatar Jun 10 '19 07:06 Banda17

try converting to JSON using toJSON()

sujeshthekkepatt avatar Jun 11 '19 04:06 sujeshthekkepatt

i figured it out thank you

Banda17 avatar Jun 18 '19 08:06 Banda17

How did you access the value of the photo? I have the same problem

Fernandogdo avatar Mar 01 '20 08:03 Fernandogdo