NodeJs error Mysql throw err;

0

The error is that when trying to register a user the records are saved correctly in mysql, but in the console it shows me an error

web.post('/registro_home', function (req,res){//AQUI INICIA EL REGISTRO DE NUEVOS USUARIOS
    
var data={
    user_log_in:    req.body.username,
    nombre:         req.body.nombre,
    apellido:       req.body.apellido,
    ced_ident:      req.body.ci,
    mail:           req.body.mail,
    passwd:         req.body.pass1,
    fecha_nac:      req.body.f_nac,
    type_user:      req.body.tipousuario,
    location:       req.body.location,
    state:          'Active',
    sqlquery:          function(){
        return 'INSERT INTO users(user_log_in,nombre,apellido,ced_ident,mail,passwd,fecha_nac,type_user,location,state,fecha_ingreso) VALUES ("'+this.user_log_in+'","'+this.nombre+'","'+this.apellido+'","'+this.ced_ident+'","'+this.mail+'","'+this.passwd+'","'+this.fecha_nac+'","'+this.type_user+'","'+this.location+'","'+this.state+'",CURDATE());';
        
    }
};
console.log(data.sqlquery());

    var query = conection.query(data.sqlquery(), function(error) {
        if (error) {
            console.log(error);
            return;
    
        } else {
            res.writeHead(200, { 'Content-Type': 'text/html' });
            res.write('<!doctype html><html><head></head><body>' +
                'Se cargo el articulo<br><a href ="index.html">Retornar</a></body></html>');
            res.end();
            return;
        }
        return;
    }); //Se envia query a mysql

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.write('<!doctype html><html><head></head><body>' +
        'Se cargo el articulo<br><a href ="index.html">Retornar</a></body></html>');
    res.end();
    return;
});

It shows me the following error

C:\Users\Eleazar\node_modules\mysql\lib\protocol\Parser.js:80
    throw err; // Rethrow non-MySQL errors
    ^
    
asked by Eleazar Ortega 23.09.2017 в 17:25
source

0 answers