Answer the question
In order to leave comments, you need to log in
nodejs scope?
Created mysql.js file,
put mysql module there:
var mysql = require( 'mysql' );
After I created the config.js file I
connected it after I connected the module.
In the config.js file I
registered connect to the database and got an error mysql undefined,
how so?
In order for everything to work, I connected mysql already in the config.js
Connect file, I declared the db variable.
And then I called it all in the server.js file, and again db is not defined.
That is: server.js file
var mysql = require( 'mysql' );
require( './config' );
db.query( 'SELECT * FROM name', function( error, result, fields ) {
} );
//error db - undefined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question