Regarding the return of the GetUsersList
method from the question you have the following issues:
- The
GetUsersList
should return something. You are wrongfully assuming that thereturn
statement from inside theforEach
is the return of theGetUsersList
method - The result of the map should be concatenated somehow so your program doesn't have activity without any result
A possible right way to accomplish what you want would be like this:
GetUsersList: function (fillInfo) {
// Array to hold all the data
var returnVal = [];
fillInfo.forEach(function (item) {
// Inside forEach handler
var users = item.get('users');
var usersContentData = users.get('content').map(function (entity) {
// Inside map handler
return entity.get('data');
});
// No return here so the forEach doesn't interrupt and instead we append data to the returnVal array
returnVal.push(usersContentData);
});
// Return the array that contains items pushed inside forEach handler
return returnVal;
}