async function prepareUser(user: any, result: any[]): Promise<void> {
let userInfo = {
email: user.email,
age: user.age,
sex: user.sex,
tel: user.tel,
avatar: user.avatar,
};
if (!userInfo.avatar) {
result.push(userInfo);
return;
}
const base64 = await imageToBase64(user.avatar);
userInfo.avatar = "data:image/jpeg;base64," + base64;
result.push(userInfo);
}
async function getUsers(req: any, res: any): Promise<void> {
const resUsers = [];
const users = await userRepository.find();
await Promise.all(users.map((user) => prepareUser(user, resUsers)));
res.json(resUsers);
}
НО ВЕДЬ В КОДЕ Я ЯВНО УКАЗАЛ ЗАГОЛОВОК