I'm trying to get the profile details of some users from my database through their usernames.
for (var i = 0; i < this.all_data.length; i++) {
this.moduleGetUserProfileByUserName({
username: this.all_data[i].userCreated
}).then(data => {
this.user_data = data.data;
console.log(this.user_data);
});
}
But I need to add the data that I am getting, to the same object the username
came from, like this.all_data[i].UserData = this.user_data;
but I cannot do this inside then
because [i]
is undefined, and I can't do it outside of moduleGetUserProfileByUserName
because then it gets executed before user_data
has any data.
What's the correct way to go about this?