The call to getCurrentItem() should be inside of a dataset.onReady() event handler to ensure that the dataset is ready before trying to access it. Otherwise nothing will be returned and item will be undefined . You should have something like this:
$w("#myDataset").onReady( () => {
let item = $w('#zipcodeset').getCurrentItem();
} );
Or you could just put it inside of the onMessage() function:
$w("#c1").onMessage((event) => {
let item = $w('#zipcodeset').getCurrentItem();
if (wixWindow.formFactor === "Mobile") {
$w("#c1").postMessage(item.chart1Mobile);
} else {
$w("#c1").postMessage(item.chart1);
}
}
BTW - I think your code is missing a closing bracket for the onMessage function.