Skip to content

Commit

Permalink
Add get searched users util function
Browse files Browse the repository at this point in the history
  • Loading branch information
ZahariCheyrekov committed Apr 5, 2023
1 parent 2314403 commit 309528b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server/src/utils/userResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,30 @@ export const createUserResultObject = (user, token) => {
_id: user._id,
token: token
}
}

export const getSearchedUsers = (usersArray) => {
if (usersArray.length === 0) return [];

const arrayResult = [];

usersArray.forEach(user => {
const {
_id,
nickname,
followers,
following,
profilePicture
} = user;

arrayResult.push({
_id,
nickname,
followers,
following,
profilePicture
});
});

return arrayResult;
}

0 comments on commit 309528b

Please sign in to comment.