I have a function which am trying to get it to return a knex result from the the database using return but it does not seem to work? I am working with knex library not ajax.
Code
//function
function runKnex(){
//Run Queries and send Content
var result = knex.select().table('User')
return result.then(function(rows){
return rows;
})
}
//calling function
mainWindow.webContents.on('did-finish-load',()=>{
const knexres = runKnex();
console.log(knexres);
});
Results
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined
}
Why is it not the array? How do i get it to return an array ?
NB when you
console.log(rows)
you get:
[
{ UserId: 1, FirstName: 'Tarik', LastName: 'Guney', Age: 30 },
{ UserId: 2, FirstName: 'Sumeyye', LastName: 'Guney', Age: 29 }
]