Code Works in Preview Not in Live Site

Hi, you need to run the code only after the dataset is ready.
See:
https://www.wix.com/velo/reference/wix-dataset/dataset/onready

If you won’t put it inside dataset.onReady block, it might run the code before you retrieve the data from the dataset.

import wixData from 'wix-data';
$w.onReady(function () {
    $w('#myDataset').onReady(() => {
        //... the code
    })
})