Refresh dataset in header

Hello, I want to display content from a collection in a repeater on each page in the header, so I put two datasets in the header. I usually (not always) get the following error message:

UserError: datasetApi ‘refresh’ operation failed Caused by DatasetError: The dataset didn’t load yet. You need to call refresh inside the onReady for the dataset.

In masterPage.js I have the following code, which I believe does exactly what is requested. Without success. I would be very happy about any help.

$w . onReady ( async function () {
await $w ( “#datasetOne” ). onReady (() => { $w ( ‘#datasetOne’ ). refresh (); });
await $w ( “#datasetTwo” ). onReady (() => { $w ( ‘#datasetTwo’ ). refresh (); });
});

$w.onReady(()=> {
	$w("#datasetOne").onReady(() => {
		$w('#datasetMyOne').refresh()
		.then(()=> { 
         	console.log("Done refreshing the dataset1");
         });
	});
	
	$w("#datasetTwo").onReady(() => {
		$w('#datasetMyTwo').refresh()
		.then(()=> { 
         	console.log("Done refreshing the dataset2");
         });
	});
});

Why do you use different IDs for the same DATASETs ???
Is it —> “datasetTwo”
Or is it —> " datasetMyTwo"
???

Sry my fault. I renamed it for the example and forgot to remove the “my”. They have the same ID:

$w . onReady ( async function () {
await $w ( “#datasetOne” ). onReady (() => { $w ( ‘#datasetOne’ ). refresh (); });
await $w ( “#datasetTwo” ). onReady (() => { $w ( ‘#datasetTwo’ ). refresh (); });
});

Thanks for the tip to check in the console.log if the run worked. The console.log always says that refresh worked. With and without error message before.