javascript - MariaSQL Nodejs no function return -


im pretty new in js , ive problem following code:

console.dir(request("select id viewer order id desc limit 1;"));    ...    function request(query){  	var answer = "test";  	var query = c.query(query);  	query.on('result', function(res) {  	  res.on('data', function(row) {  	    console.dir(row);  	    answer = row;  	  })  	});  	  	return answer;  }

the second console.dir returns expected answer { id: '1' }, first 1 returns "test". seems 'answer = row;' has no effect.

does can explain me behavior , can tell me how solve ?

thanks in advance, ystro :)


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -