I have a task for school to make a web application or api endpoint with json data. I need to display all that data and to display their friends, and friends of friends within persons object. Apparently I stopped here cause all my values within array in console are not defined (http://prntscr.com/i9i477), can someone help me with this, thanks !
class Osoba {
constructor(id, firstName, surname, age, gender, friends) {
this._id = id;
this._firstName = firstName;
this._surname = surname;
this._age = age;
this._gender = gender;
this._friends = friends;
}
get id() {
return this._id;
}
set id(id) {
this._id = id;
}
get firstName() {
return this._firstName;
}
set firstName(firstName) {
this._firstName = firstName;
}
get surname() {
return this._surname;
}
set surname(surname) {
this._surname = surname;
}
get age() {
return this._age;
}
set age(age) {
this._age = age;
}
get gender() {
return this._gender;
}
set gender(gender) {
this._gender = gender;
}
get friends() {
return this._friends;
}
set friends(friends) {
this._friends = friends;
}
}
osobe = [];
$(function() {
$.getJSON('https://raw.githubusercontent.com/Steffzz/damnz/master / data.json ', function(data) {
var json = jQuery.parseJSON(JSON.stringify(data));
for (person in json) {
var _id = person['id'];
var _firstName = person['firstName'];
var _surname = person['surname'];
var _age = person['age'];
var _gender = person['gender'];
var _friends = person['friends'];
x = new Osoba(id = _id, firstName = _firstName, surname = _surname,
age = _age,gender = _gender, friends = _friends);
osobe.push(x);
}
})
});
console.log(osobe);