YZ
router.get('/users/me', isAuthenticated,
async (req, res) => {
try {
const userId = req.user;
const userInfo = await User.findByPk(userId);
const user = await User.findOne({
include: [{
model: Image,
as: 'image',
where: { id: userInfo.avatar_id },
}],
});
return res.json({ error: false, data: user });
} catch (error) {
console.log(error);
res.status(500).json({ error: true, message: 'Something was wrong!' });
}
});const user = await User.findOne({
include: [{
model: Image,
as: 'image'
}],
where: { userId }
});

