Problem in delete item button in repeater

Hello, please help me with this problem: Why does the button to delete the item from the repeater not work at the first onClick, and after clicking it, it performs the function once more?


export function deleteItinerary_click(event) {

$w("#repeater3").forEachItem(($item, itemData, index)=> {
$item("#deleteItinerary").onClick (()=>{
product_name= itemData.myPlacesListName;
let userId = user.id;
wixData.query("myItinerary")
.eq("userId", userId)
.eq("myPlacesListName", product_name)
.find()
.then((results) => {
let items = results.items;
let firstItem = items[0];

wixData.remove("myItinerary", firstItem._id).then( () => {
getfilters2();
console.log("borrado de itinerario")

});
})
})
})
}

That’s exactly what this code is supposed to do. You have button.onClick() inside button.onClick.
delete this code and use the following instead:

let product_name;
$w.onReady(() => {
 let userId = user.id;
 $w("#repeater3").onItemReady(($item, itemData, index)=> {
  $item("#deleteItinerary").onClick (()=>{
  product_name= itemData.myPlacesListName;
  wixData.query("myItinerary")
  .eq("userId", userId)
  .eq("myPlacesListName", product_name)
  .find()
  .then((results) => {
     let items = results.items;
     return items[0];
   }).then(firstItem => {
    return wixData.remove("myItinerary", firstItem._id);
   })
   .then( () => {
     getfilters2();
     console.log("borrado de itinerario")
    })
   })
 })
})

Thank you very much for your help.