JSFiddle - React, Tailwind, and code Playground
JavaScript
function Invoice() {
this.read = function(callback_fun){
var stmnt = "SELECT * FROM invoices ORDER BY ID DESC";
// function callback(callback_fun){
var myrows = [];
db.transaction(function(tx){
tx.executeSql(stmnt, [], function(tx,result){
debugger;
for(var i = 0; i < result.rows.length; i++){
var row = result.rows.item(i);
myrows.push(row);
}
callback_fun(myrows);
}, function(tx,error){
alert('Error: '+error.message);
return;
});
});
};
};
var newInvoice = new Invoice();
var myResult;
newInvoice.read(function(r) {
debugger;
myResult = r;
});
setTimeout(function(){ alert(myResult); }, 6000);