Query not working online

That’s my code

import wixData from 'wix-data';

wixData.query("Formulario1")
 .descending("id")
 .limit(1)
 .distinct("id", {"suppressAuth": true, "suppressHooks": true})
 .then(r => {
 let lastItem = r.items[0];
 let newId;
  console.log(lastItem)
  lastItem ? newId = lastItem + 1 : newId = 1;
  console.log(newId)
  $w('#input10').value = newId
 })

Works perfect on the editor, but not on the site online, I have no idea why, the database is open to everyone. I want to create a “Order number” when new data is submitted. ¿Any suggestion?

Your SANDBOX-DB is synced with LIVE-DB?

yes

@agenciafxsoluciones
Question: What exactly do not work? Do you get any ERRORs ?