I’ve got some code that looks at the user’s ID and pulls a number called ‘tier’ from the backend. I then use ‘tier’ to query a collection and return the results to a table that is initially collapsed. There is a button allowing someone to look at the options that were returned to the table.
All of the described actions above work pretty well when viewing the project using Preview. It can sometimes be slow filling the table but it works. However, when I view from the published site (in Chrome) it give an error code about uncaught promise before filling the table. I tried using a timeout to slow filling the table but it didn’t seem to work. Any suggestions?
$w . onReady ( function () {
tester ();
});
export async function tester ( ){ let bytier = await set_player_level ( currentUser . id );
console . log ( bytier ); //this gives proper result in preview let myRecievedDataFromBackend = await get_jobs ( bytier );
$w ( “#table1” ). rows = myRecievedDataFromBackend ;
//setTimeout(() => {$w(“#table1”).rows = myRecievedDataFromBackend},10000);
console . log ( myRecievedDataFromBackend ); //this gives proper result in preview
}
I set the two collections to allow anyone to view the data. Still getting the error. I’m wondering if I should change the way I did this so that OnReady I send a filter to the page’s dataset based on the result of the first query. The reason I did it this way was to load only what I want the user to see. I don’t want them to see items of a different tier and then those disappear as the filter takes effect.
My code keys in on the unique identifier of owner (automatically assigned by Wix). As the Admin, all of the sample data I’ve put in the collection is under that owner. Thus in preview mode I see them all and the functions work.
When I go to the published side of things my owner ID changes (no longer the same as the Admin). When I queried the collection there was no data for me to read because none of the records existed for the different owner I was assigned. To solve everything, I created a new entry into the collection via a form on the public site and now it all works.