The onReady I mentioned refers the dataset, add
$w("#myDataset").onReady( () => {
});
after the “$w.onReady” and insert your code in the brackets.
To check the results you can implement this code after you get the items:
console.log(results.items);