There is a code for checking the existence of the user, which is executed but, if the user exists, he should issue a "user exists" to the console and stop the program.
Instead, the program is executed and a new user is written to JSON (a duplicate is created) and three entries are created:
Here is the code itself:
app.use("/register", function (request, response) { console.log(request.body); fs.readFile("./data/users/users.json", "utf-8", function (err, text) { if (err) { console.log("ERROR READING FILE" + err); } else { var users = JSON.parse(text); for (var i = 0; i < users.length; i++) { if (users[i].email === request.body.email) { console.log("user already exists"); break; } else { users.push(request.body); fs.writeFile("./data/users/users.json", JSON.stringify(users), function () { // write new user to json }); } } } }); }); Can someone have an example of a registration / authorization form with checks on Angular & Express?

request.body.emailmatches notusers[0].email, butusers[1].email? - Grundyreturn;? - Insider