我正在尝试获取给定用户“关注列表”中每个用户的“关注列表”(getList()返回该列表) 但以下每个用户的列表相同
class User {
constructor(username){
this.username = username;
};
async scan(current=1, total=1) {
console.log(`\nScanning ${this.username} [${current}/${total}]`); // useful when scanning lot of users
await getList(this.username).then((list) => { // obtaining list
this.following = list; // setting list as property
for(let i=0; i<this.following.length; i++){
this.following[i] = new User(this.following[i]); // converting usernames to Users
};
});
};
async deepScan() {
for(let i=0; i<this.following.length; i++){
await this.following[i].scan(i+1, this.following.length);
}
};
};
let user = new User("emijerochim"); // CREATING USER
user.scan() // SCANING USER
.then(() => user.deepScan()); // SCANING USER CONTACTS
我认为这是一个范围问题,但是“ Scanning this.username”总是返回正确的用户名,该用户名该列表正在扫描,但是给定的列表对该用户名不正确。因此,我假设列表已被正确扫描,但分配给该用户的列表不是其结果。