0

I 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.

Output screenshot of k value

enter image description here

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

instead of the JSON Object

15
  • console.log(k)? Commented Jun 10, 2019 at 6:35
  • Try logging k alone and check if it has Photo property in it. Also, check if k is an object instead of a string. Commented Jun 10, 2019 at 6:36
  • the above JSON object i have presented is the k value that i have printed in console.it has the Photo property but i am unable to grab it. @YashwardhanPauranik Commented Jun 10, 2019 at 6:39
  • Can you add a screenshot of the console.log(k)? Did you check if k is stringified or parsed? Commented Jun 10, 2019 at 6:42
  • Show us the code from profiledata Commented Jun 10, 2019 at 6:44

1 Answer 1

1

I solved it thank You for the help this.auth.profiledata().then(k => this.profileData = k);

The issue was raised due Asynchronous promise catch. i used .then() to complete the promise and get the access to the JSON object

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.