Get item does not show on live

Hi Guys,

I created a spin the wheel. Customer input email first time to start the spin. After getting voucher from the spin, I want to send the confirmation from the inserted email. However, when i get item from first form and pass to other, it worked on preview but not on publish.

Could you please help me! Below is the code

Thank you

let couponArray;

$w.onReady(async function () {
 let results = await $w("#couponsDataset").getItems(0,32);
    couponArray = results.items;
    $w('#textGroup').children.forEach((element, index) => {
        element.text = couponArray[index].couponname;
    });
});

function randomizeSpinner(array) {
 let shuffledArray = shuffleArray(array);
    $w('#textGroup').children.forEach((element, index) => {
        element.text = shuffledArray[index].couponname;
    });
}

function showPrize() {
 let prize = $w('#winningCoupon').text;
 let fadeOptions = {
 "duration":   50000,
 "delay":      100000
}
 let coupon = couponArray.find((element, index) => {
 return element.couponname === prize;
    });
    $w('#prizeName').text = `​${coupon.couponname}`;
    $w('#box3').expand();
    $w("#box2").collapse('fade');
    }

import {session} from 'wix-storage';
export function spinButton_click() {
session.setItem('input1', $w('#input1').value);

 let spinOptions = {
 "duration": 1500,
 "delay": 1,
 "direction": "ccw",
 "cycles": 2
    };

    $w('#box1').hide('spin', spinOptions).then(() => {
        $w('#box1').show('spin');
        randomizeSpinner(couponArray);
        showPrize();           
    });
}

function shuffleArray(array) {
 for (let i = array.length - 1; i > 0; i--) {
 const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
 return array;
}

import wixLocation from 'wix-location';
import wixData from 'wix-data';

var prizeName
var email

$w.onReady(function () { 
 
});

export function button28_click() {
    email =      $w('#input2').value
    prizeName =      $w('#prizeName').text
    console.log("You clicked on the SUBMIT-BUTTON, the new DATA will be saved now!")
    $w('#dataset1').onReady(()=>{
        $w('#dataset1').setFieldValue("prizeName",prizeName)
        $w('#dataset1').setFieldValue("eMail"   ,   email)
    })
    $w("#dataset1").save()
}

export function button27_click() {
    $w.onReady(function () {
 const input2 = session.getItem('input1');
    $w('#input2').value = input2;
});
$w('#input2').value =$w('#input1').value
$w('#input3').value =$w('#prizeName').text
$w("#input3").readOnly = true;
if ($w('#form2').collapsed){
$w('#form2').expand('fade');
}
else
$w('#form2').collapse('fade');
}

Everytime, when Code is running on preview-mode, but not in live, then you have first to check …

  1. if preview & live-data is synced.
  2. if you have setted-up the right database-permissions.