How to download files from Dynamic Database

One issue that I see is that you are incorrectly using a dataset onReady() function inside of an onClick() event handler.

$w('#button1').onClick(()=>{
   $w("#dynamicDataset").onReady(()=>{

The only place that the onReady() is needed is inside of the page’s onReady() function, when you need to perform actions right after the dataset has loaded its data from the collection and updated all connected page elements with their corresponding values.

Otherwise, the code won’t run as you expect it to with a dataset onReady() inside of an event handler.