From 55aed6d7c2df0daedbdabea0d1727acb1815ce2b Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Fri, 26 Jul 2024 21:21:03 +0530 Subject: added upload feature --- backend/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'backend') diff --git a/backend/index.js b/backend/index.js index 5bcc507..c7ac324 100644 --- a/backend/index.js +++ b/backend/index.js @@ -82,6 +82,18 @@ app.post('/login', async (req, res) => { } }); +// Fetch ads route +app.get('/ads', async (req, res) => { + try { + const adsSnapshot = await db.collection('ads').get(); + const ads = adsSnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() })); + res.json(ads); + } catch (error) { + console.error('Error fetching ads:', error); + res.status(500).send('Error fetching ads'); + } +}); + const PORT = 5000; app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); -- cgit v1.2.3-59-g8ed1b