Hello Ron,
.getTotalItems() returns a promise not an actual value so to get the count:
export function page1_viewportEnter(event) {
$w("#dataset1").getTotalCount()
.then((count) => {
console.log(count);
$w("#txtRecCount").text = count.toString();
});
}
.then() is used to resolve the promise and get the value returned from that promise.
Read more about promises here.
Best,
Majd