0 points

Sharing data from API to Social media ( twitter and facebook )


dashboard

Sat Nov 07 2020 20:07:02 GMT+0000 (UTC)

Posted by @jpannu

function shareQuote(socialMedia){
    const quote = quoteElem.textContent;
    const author = authorElem.textContent;

   const tweetUrl = `http://${socialMedia}.com/intent/tweet?text=${quote}-${author}`;
 
   window.open(tweetUrl , '_blank');

}

facebookBtn.addEventListener('click', shareQuote.bind(this,"facebook"))
tweetBtn.addEventListener('click' ,  shareQuote.bind(this,"twitter") );
content_copy Copy