You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sergio edited this page Oct 24, 2020
·
4 revisions
schema of the basic addEventListener, fetch() and callback:
constEMPTY_HEART='♡'constFULL_HEART='♥'letheartStates={"♡": "♥","♥": "♡"};letarticleHearts=document.querySelectorAll(".like");functionlikeCallback(e){letheart=e.target;fetch("/bogus_url").then(function(serverMessage){heart.innerText=heartStates[heart.innerText];}).catch(function(error){console.log('there was an error)
});}for(letglyphofarticleHearts){glyph.addEventListener("click",likeCallback);}