UniversityOfSaskatchewanCMPT371 / term-project-2024-team-4

Apache License 2.0
2 stars 2 forks source link

querying databases creating the issue of non-numeric value #96

Closed Uv2002 closed 5 months ago

Uv2002 commented 6 months ago

/ GET: Fetch Sites by Location router.get("/catalougesite/:location", async (req, res) => { const { location } = req.params; // geting the query try { const siteRepository = await myDatabase.getRepository(Site); // get the name of all the sites with location const sites = await siteRepository.find({ where: { location }, select: ["name"], }); if (sites.length > 0) { const siteNames = sites.map((site) => site.name); // 200 found the sites with given location res.status(200).json(siteNames); } else { // 404 not found the location and sites res.status(404).send("Not available"); } } catch (error) { console.error("Error fetching Sites:", error); // 500 error while fetching the sites res.status(500).json({ error: error.message }); } }); tried to call this end point but get an error of non-numeric value

itsjorden commented 6 months ago

Could you provide more information about this error? Which branch was this on, how was this endpoint called(in a test file or from a script)?

Uv2002 commented 5 months ago

it should be in sites.js