mirror of
https://github.com/itsnaveenk/bazar3.git
synced 2025-12-19 21:57:06 +00:00
18 lines
525 B
JavaScript
18 lines
525 B
JavaScript
const db = require('../db');
|
|
|
|
exports.getAllTeams = async (req, res) => {
|
|
console.log('Fetching all teams...');
|
|
try {
|
|
const teams = await db.query('SELECT * FROM teams');
|
|
if (!teams.length) {
|
|
console.log('No teams found.');
|
|
return res.status(200).json({ error: 'No teams found.' });
|
|
}
|
|
console.log(`Fetched ${teams.length} teams.`);
|
|
res.json(teams);
|
|
} catch (error) {
|
|
console.error('Error fetching teams:', error);
|
|
res.status(500).json({ error: 'Failed to fetch teams' });
|
|
}
|
|
};
|