I have an object:
data = { badges: [ 0: { img:"/assets/img/badges/024-medal-31.png", title:"Rank 1" } ], email: "usermail@mail.com", id: "12345678", joinDate: timestamp, name: "User Name", } In the array of badges can be as many objects of the same structure. Why does the following code not do anything at all?
$.each(data.badges, function() { console.log(this.img); }); each completely ignored, do not tell me why and how to get the information of each object in the badges ?
JSON.stringify (data):
{"badges": [], "email": "usermail@mail.com", "joinDate": "timestamp", "name": "User Name", "id": "12345678"}
The data created earlier approximately as follows:
let userBadges = []; userInfo.badges.forEach(doc => { doc.badgeRef.get() .then(res => { userBadges.push( res.data() ) }) //data() = обьект {img: , title:} }); data.badges = userBadges;