Help with getCurrentCart update

Hello everyone,
I am trying to get all Cart Items to be in a text, but the problem is that my code breaks as soon as I do not have exact 5 products on the cart and for the text to update I had to add a piece of code to refresh the whole page.
I am wondering if it is possible to get the quantity and SKU code according to the total items in the cart and to refresh the output automatically when the cart gets updated.
Thanks in advance!

Find the code I’m using below:

import wixStores from ‘wix-stores’ ;
import {getCurrentCart} from ‘backend/getCurrentCart.jsw’ ;
import wixLocation from ‘wix-location’ ;

$w.onReady( async function () {
const results = await getCurrentCart();

$w( ‘#item0’ ).text = results.lineItems[ 0 ].quantity.toString() + "x " + results.lineItems[ 0 ].sku.toString();
$w( ‘#item1’ ).text = results.lineItems[ 1 ].quantity.toString() + "x " + results.lineItems[ 1 ].sku.toString();
$w( ‘#item2’ ).text = results.lineItems[ 2 ].quantity.toString() + "x " + results.lineItems[ 2 ].sku.toString();
$w( ‘#item3’ ).text = results.lineItems[ 3 ].quantity.toString() + "x " + results.lineItems[ 3 ].sku.toString();
$w( ‘#item4’ ).text = results.lineItems[ 4 ].quantity.toString() + "x " + results.lineItems[ 4 ].sku.toString();

$w( ‘#pedidoTotal’ ).text = $w( ‘#item0’ ).text + "; " + $w( ‘#item1’ ).text + "; " + $w( ‘#item2’ ).text + "; " + $w( ‘#item3’ ).text + "; " + $w( ‘#item4’ ).text;

$w( “#button1” ).onClick( (event) => {
wixLocation.to(wixLocation.url);
} );