fix
This commit is contained in:
parent
06a2c0f0a3
commit
328ae3d9ad
@ -135,11 +135,27 @@ router.post('/list', async (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/read/:id', async (req, res) => {
|
||||
if (!req.body.id) {
|
||||
return res.status(400).json({ error: 'id is required' });
|
||||
try {
|
||||
const id = req.params.id;
|
||||
|
||||
if (!id) {
|
||||
return res.status(400).json({ error: 'id is required' });
|
||||
}
|
||||
|
||||
const message = await Message.query()
|
||||
.findById(id)
|
||||
.withGraphFetched('[temp_email]')
|
||||
.first();
|
||||
|
||||
if (!message) {
|
||||
return res.status(404).json({ error: 'Message not found' });
|
||||
}
|
||||
|
||||
res.json(message);
|
||||
} catch (error) {
|
||||
console.error('Error fetching message:', error);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
const message = await Message.query().where('id', req.body.id).withGraphFetched('temp_email').first();
|
||||
res.json(message);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Loading…
x
Reference in New Issue
Block a user