There is nothing to fix. The way you have written the code is wrong here. You should be putting the .getCurrentItem() under a Dataset onReady() function as Anastasiia mentioned above.
$w.onReady(function () {
$w("#dataset1").onReady( () => {
let textFromDatabase = $w("#dataset1").getCurrentItem().title;
$w("#text1").text = textFromDatabase;
});
});