mysql.query('SELECT accountID,deviceID FROM EventData WHERE accountID = "'
+ acc
+ '" AND deviceID = "'
+ deviceID
+ '" ORDER BY timestamp DESC LIMIT 1 ',
function(err,rows,fields) {
if (rows.length > 0) {
var accountID = rows[0].accountID;
var deviceID = rows[0].deviceID;
var re2 = ({
title: deviceID,
});
console.log(re2)
console.log("aaa")
}
);
The above code produces the following output :
[{ title: 'dev1'}]
aaa
[{ title: 'dev2'}]
aaa
But I expected to see the following:
[{ title: 'dev1'},
{ title: 'dev2'}]
aaa
What am I doing wrong?
re2is not an array, it's an object.