fix: display error message when user or channel does not exists

This commit is contained in:
Lukian LEIZOUR 2025-04-18 18:39:56 +02:00
parent 17c6ab79ca
commit 2b2a38682a
5 changed files with 80 additions and 33 deletions

View file

@ -35,7 +35,7 @@ router.get('/:name', async (req, res) => {
if (channel[0]) {
res.send(channel[0]);
} else {
res.send('No channel found');
res.status(400).send({ error: 'No channel found' });
}
});

View file

@ -21,7 +21,7 @@ router.get('/:username', async (req, res) => {
if (user[0]) {
res.send({id: user[0].id, username: user[0].username, admin: user[0].admin});
} else {
res.send('No user found');
return res.status(400).send({ error: 'No user found' });
}
});