Heyya!
ok so, I was making api where when someone replace the :id /api/v1/codes/:id with the code they get it from /api/v1/code (this works fine). whenever they receive the code from there, the api will automaticly save the code as well in the JSON file. I'm trying to make a route where when user replace the :id with the code given and the code exist in the json file, it will return "code valid" and if the code doesnt exist, negation of it will happen.
The code
const jsonfile = editJsonFile(`./codes.json`)
const datas = jsonfile.get("codes.")
const data = datas.find(c => c.find === JSON.parse(req.params.id))
if (!data) res.status(404).send("The code wasnt found in the database")
res.send(code);
});
my JSON file
{
"codes": [
"OjeI",
"SeY7",
"41gx",
"A7PA",
"b6AO",
"5bWO",
"WALz",
"iDaq",
"3KqH"
]
}