Fix response status code for no teams found in getAllTeams function

This commit is contained in:
Naveen Kumar 2025-04-22 02:37:40 +05:30
parent 16d859b815
commit 1a01bd45d1

View File

@ -6,7 +6,7 @@ exports.getAllTeams = async (req, res) => {
const teams = await db.query('SELECT * FROM teams');
if (!teams.length) {
console.log('No teams found.');
return res.status(404).json({ error: 'No teams found.' });
return res.status(200).json({ error: 'No teams found.' });
}
console.log(`Fetched ${teams.length} teams.`);
res.json(teams);