1
hello
I have that code:
router.post('/loginCli', function(req, res, next) {
var j;
conn.query('SELECT * FROM bdlabella.tbclientes order by email_cli', (err, results) => {
if(err){
console.log(err);
}
// valida se o email ja existe no banco.
var dados = results;
dados.forEach(function(row){
if(row.email_cli == req.body.email_cli){
loginCli.render(req, res, "Usuario ja cadastrado com esse email!");
} else if(req.body.senha_cli != req.body.Csenha_cli){//valida se as senha == confirmar senha
loginCli.render(req, res, "Senha nao compativel");
} else {
loginCli.save(req.body).then(results =>{
loginCli.render(req, res, null, "Cadastro realizado com sucesso!");
break;
}).catch(err=>{
loginCli.render(req, res, err);
});
}
});
});
});
And he’s making that mistake when it comes to saving in the bank
POST /loginCli 200 150.578 ms - 4375
GET /css/bootstrap.css 304 1.845 ms - -
GET /css/estilo.css 304 6.180 ms - -
GET /engine0/style.css 304 0.842 ms - -
GET /js/main.js 304 1.798 ms - -
GET /engine0/jquery.js 304 2.988 ms - -
[nodemon] restarting due to changes...
[nodemon] starting `node ./bin/www`
labelle:server Listening on port 3000 +0ms
C:\E. S\laBelle\routes\index.js:68
break;
^^^^^
SyntaxError: Illegal break statement
at process.nextTick (C:\E. S\laBelle\node_modules\mysql2\lib\commands\query.js:72:16)
at processTicksAndRejections (internal/process/task_queues.js:79:9)
[nodemon] app crashed - waiting for file changes before starting...
Talking about you can’t use the break
, only that if I don’t use it and will save in the bank the number of times referring to the records that already have there
for example has 2 records, it goes there and saves the same thing 2 times.
What’s the idea of having
break;
in the code? What do you want thatbreak;
do?– Sergio