I have the content script of a chrome extension containing a function which is supposed to fire only when a particular button is clicked. But I notice that the function is fired once when the button is clicked and it keeps on calling itself multiple times( not infinite)
button.addEventListener("click", handleButtonClick);
function handleButtonClick() {
extractedData = function3();
// Your custom logic for button click
setTimeout(() => {
fillContentEditableWithDummyText('Loading...')
fetch('a valid end point',{
method: "POST",
body: JSON.stringify({
email: user.email,
extractedData: extractedData
})
}).then(res => res.json()).then(data => fillContentEditableWithDummyText(data.message))
},300);
//fillContentEditableWithDummyText();
}
When I tried to debug, noticed that once function3() is returned, the handleButtonClick() function is called again