My “BASProducts” database is populated BEFORE redirecting to second page. On the second page, a “BASProducts” database is connected a Table through a dataset, which is readied in this onReady function that runs inside the page’s onReady function:
$w . onReady ( function () {
$w ( “#dbBASProducts” ). onReady ( () => {
console . log ( “The #dbBASProducts dataset is now ready” );
)};
The problem is that the Table on the second page is displayed BEFORE the backend function executed from the first page has completed its work. When this happens, the Table displays only part of the data, ranging from none to all of it. How can my code ensure the BASProducts database has been completely filled BEFORE displaying the data on the second page?
In case this is relevant, this is the backend code that populates the database. While I know of no problem with this backend code, I am providing it for reference.
If you require any more code to analyze the problem, I will be happy to provide it.
BACKEND CODE:
export async function insertData ( db , toInsert ) {
let results = await wixData . insert ( db , toInsert )
try {
let item = results ; //see item below
console . log ( "backend insertData function: inserted this item into " + db + " database => " , item )
}
catch ( err ) {
let errorMsg = err ;
console . log ( "errorMsg = " , errorMsg )
}
}