0

My firebase API returned JSON looks like below

{    
 one:{  
     fullName: "1",
     id: "1",
     subDistrict: "1"
     zone: "1"  
    },  
two:{  
     fullName: "2",
     id: "2",
     subDistrict: "2"
     zone: "3"  
   },   
}

I have created data model likes below

interface users{
  user: data
}

interface data { 
  fullName:string,
  id:string,
  zone:string,
  subDistrict:string
}  

I am receiving procedure form angular firebase

this.source=(<users>snap.val());  

data is recieved properly,

console.log(this.source) //ok

But I am not able to access it

console.log(this.source.user);//undefined 

1 Answer 1

1

The reason is because your this.source doesn't contain user key. If your format of your json is as you mentioned, you should do this:

console.log(this.source.one, this.source.two);

... instead of

console.log(this.source.user);
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.