From f86bfee3f391615f76529050deff3fce0a11e81c Mon Sep 17 00:00:00 2001 From: Aarish <118203269+ImprobableGenius@users.noreply.github.com> Date: Sun, 25 May 2025 17:14:26 -0500 Subject: [PATCH] Updat name - getByDomainName() returns an array --- routes/sites.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/routes/sites.js b/routes/sites.js index a2cb1e5..7817f3c 100644 --- a/routes/sites.js +++ b/routes/sites.js @@ -44,19 +44,21 @@ router.get('/:id', async function(req, res, next) { */ router.get('/domain/:domain', async function(req, res, next) { const domainName = req.params.domain; - let site = null; + let sites = null; try { - site = await siteModel.getByDomainName(domainName); + sites = await siteModel.getByDomainName(domainName); } catch (error) { console.error('Error fetching site by domain name:', error); return res.status(400).send('Error fetching site: ' + error.message); } - if (!site || site.length === 0) { + console.log('Site found:', sites); + + if (!sites || sites.length === 0) { return res.status(404).send('Site not found'); } else { - res.json(site[0]); // Return the first match + res.json(sites[0]); // Return the first match } });