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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -