Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
andifahruddinakas committed Oct 24, 2024
1 parent ebd4a3a commit 58e6040
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ app.get("/api/desa", (req, res) => {

app.get("/api/desa/:kodedesa/:tahun", (req, res) => {
const { kodedesa, tahun } = req.params;
const filePath = path.join(
__dirname,
"public",
"desa",
kodedesa,
tahun + ".json"
);
const folderPath = path.join(__dirname, "public", "desa", kodedesa);
const filePath = path.join(folderPath, tahun + ".json");

if (!fs.existsSync(folderPath)) {
return res.status(400).json({
status: 400,
error: true,
message: `kodedesa ${kodedesa} tidak dikenali`,
});
}

if (
!fs.existsSync(path.join(__dirname, "public", "desa", kodedesa)) ||
!fs.existsSync(filePath)
) {
if (!fs.existsSync(filePath)) {
return res.status(400).json({
status: 400,
error: true,
Expand Down

0 comments on commit 58e6040

Please sign in to comment.