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 } });