Hi
I have this query on node.js. This is my server side file:
function doquery(select,from,where,value) {
var con = mysql.createConnection({
host: "localhost",
database: "db545",
user: "root",
password: "mypass"
});
return con.query("SELECT " + select + " FROM " + from + " WHERE " + where + value);
};
io.on('connection', (socket) => {
// when the client emits 'add user', this listens and executes
socket.on('add user', (username) => {
dispname = doquery('name','members','member_id','1');
but the variable dispname is resulting in [object object] but since this is server side Im not getting any errors so I cant debug it. What is wrong?
Thank you.
--inspecttonode) and then connecting with the Chrome devtools' "node" button which will appear in the toolbar at that point - or VSCode's debugger. In VSCode you can even use the remote mode (bottom-left corner) to do the whole thing with a nice interface. This will allow you to debug code running on a server.awaitit. (It's not clear because you didn't show which mysql package you are using exactly, there are multiple.)con.querydoesn't return the result... it has a callback to return the result, you are just doing it wrong, read the documentation...con.query(your_query, function (error, results, fields) {...}