Having problems closing brackets

I am very sorry for this noob question, but my js file shows 5 errors, but all my brackets seem closed.

can anyone help plase

MY JS FILE:

const targets = [...document.getElementsByName('item-id')];

const lazyLoad = target => {
          const io = new IntersectionObserver((entries, observer) => {
            entries.forEach(entry => {
    
        
              if (entry.isIntersecting) {
                entry.addEventListener("click", function(event){
                    const clickedId = event.target.value
                    const clickedBtn = document.getElementById(`like-unlike-${clickedId}`)
            
                    $.ajax({
                        type: 'POST',
                        url: "/like-unlike/",
                        data: {
                            'csrfmiddlewaretoken': csrftoken,
                            'item-id': clickedId,
                        },
                        success: function(response){
                            console.log(response.likes)
                            clickedBtn.textContent = `${response.likes} likes`
                            
                        },
                        error: function(error){
                            console.log(error)
                        }
                    })
                }));
        
                observer.disconnect();
              })
            })
          })
        
          io.observe(target);
        }
        
targets.forEach(lazyLoad);

is this supposed to be inside the addEventListener section?

It might be a good idea to add some comments to the closing brackets like

} //end if (entry..)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.