diff options
| author | Bobby <[email protected]> | 2022-05-03 22:04:51 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-05-03 22:04:51 -0400 |
| commit | 97ecf128297c65939dd196bbf731d7713ff3eb17 (patch) | |
| tree | 2e34ce476542d17871791d19fb45fd6a20d61bfa /interface/routes/api/geography.js | |
| parent | 038298fc140f8f1e0bcba02bb422ab0309a73911 (diff) | |
| parent | f1b9662122abed09ccf74b2eda034e7a45730e60 (diff) | |
| download | Welfare-Schemes-DMQL-97ecf128297c65939dd196bbf731d7713ff3eb17.tar.xz Welfare-Schemes-DMQL-97ecf128297c65939dd196bbf731d7713ff3eb17.zip | |
Merge pull request #6 from luciferreeves/main
wowowow
Diffstat (limited to 'interface/routes/api/geography.js')
| -rw-r--r-- | interface/routes/api/geography.js | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/interface/routes/api/geography.js b/interface/routes/api/geography.js index 4667db8..58e3b84 100644 --- a/interface/routes/api/geography.js +++ b/interface/routes/api/geography.js @@ -9,27 +9,38 @@ const districtController = require("../../controllers/district.controller"); router.get("/states", (req, res) => { stateController.allStates().then(states => { res.send(states); - }); - + }); }); router.get("/districts/:state_id", (req, res) => { const state_id = req.params.state_id; districtController.allDistrictsByStateId(state_id).then(districts => { - res.send(districts); + if (districts) { + res.send(districts); + } else { + res.status(400).json({ message: "No districts found" }); + } }); }); router.get("/mandals/:district_id", (req, res) => { const district_id = req.params.district_id; mandalController.allMandalsByDistrictId(district_id).then(mandals => { - res.send(mandals); + if (mandals) { + res.send(mandals); + } else { + res.status(400).json({ message: "No mandals found" }); + } }); }); router.get("/villages/:mandal_id", (req, res) => { const mandal_id = req.params.mandal_id; villageController.allVillagesByMandalId(mandal_id).then(villages => { - res.send(villages); + if (villages) { + res.send(villages); + } else { + res.status(400).json({ message: "No villages found" }); + } }); }); |
