Velo Script Not Running on Page Load

I have a script that pulls some information from an external source. When I preview it in the backend, it builds properly -but when I publish and visit the site, it doesn’t work. I did notice, if I force-refresh the page, the code runs and it populates properly. Any idea what I’m doing wrong?

import { getJSON } from ‘wix-fetch’ ;

$w . onReady ( async function () {

// GET call using getJSON
const response = await getJSON ( ‘websiteaddress.php’ )
updateRepeater ( response );
});

function updateRepeater ( response ){
console . log ( response );
$w ( ‘#ConnectRepeater’ ). data = response ;
$w ( ‘#ConnectRepeater’ ). show ();

$w ( '#ConnectRepeater' ). onItemReady ( ( $item ,  itemData ) => { 
    $item ( '#EpisodeDate' ). text  =  itemData . Date ; 
    $item ( '#EpisodeTitle' ). text  =  itemData [ 'Full Title' ]; 
    $item ( '#EpisodeDescription' ). text  =  itemData [ 'Public Description' ]; 
$item ( '#EpisodeImage' ). src  =  itemData [ 'WebImage' ]; 
}); 

};

Hi! Based on the code you provided, it seems like the problem might be related to the timing of when the data is being fetched and when the repeater is being updated on the published site. It’s possible that the data is not yet available when the repeater is being updated, which is causing it to not display the data.

import {getJSON} from 'wix-fetch';

$w.onReady(async()=>{
  const response = await getJSON('websiteaddress.php')
  updateRepeater(response);
});

function updateRepeater(response){
    console.log(response);
    $w('#ConnectRepeater').data = response;
    $w('#ConnectRepeater').show();

    $w('#ConnectRepeater').onItemReady(($i,itemData,index)=>{
       $i('#EpisodeDate').text = itemData['Date'];
       $i('#EpisodeTitle').text = itemData['Full Title'];
       $i('#EpisodeDescription').text=itemData['Public Description']
       $i('#EpisodeImage').src = itemData['WebImage'];
    });
}

What do you get as result for —>response<— ???
How do look like the OBJECT-STRUCTURE ?

Show opened OBJECT on a SCREENSHOT…