Node.js returning result from MySQL query
I have the following function that gets a hexcode from the database
function getColour(username, roomCount)
{
connection.query('SELECT hexcode FROM colours WHERE precedence = ?',
[roomCount], function(err, result)
{
if (err) throw err;
return result[0].hexcode;
});
}
My problem is that I am returning the result in the callback function but
the getColour function doesn't return anything. I want the getColour
function to return the value of result[0].hexcode.
At the moment when I called getColour it doesn't return anything
No comments:
Post a Comment