2
I’m developing an Electron application together with Node.js, and I can’t import a dependency within an object.
You can do this, import a dependency into an object?
const conexao = {
**//Acredito que o problema está aqui.**
msql = require('mysql'),
connection = msql.createConnection({
host: 'localhost',
user: 'root',
password : 'root',
database: 'bd_barbearia'
}),
criarConexao: function(){
connection.connect();
},
fecharConexao: function(){
connection.end();
},
verificarUsuario: function(nome,senha){
connect.query("call verificarCliente('"+this.nome+"','"+this.senha+"')", function(error,results){
if(error) throw error;
lista = JSON.parse(JSON.stringify(results[0]));
resposta = String(lista[0].alert);
return resposta;
});
}
};
module.exports = conexao;
Why don’t you just put the Mysql import out of the object? So you won’t need it with the various problems that the
this
of the JS brings...– Luiz Felipe