Web Share API - link and text does not appear on social media

1k Views Asked by At

I want to use web share api, so i can share specific image coming from google spreadsheet with text and description, but unfortunatelly only image is being shared to facebook. The text, title and url it's missing. For whatsapp if working fine for example. Can anyone give hand for this? Thanks

Code below:

`

async function share() {
  const imageQuote = '<?=$image_quote; ?>';
  const response = await fetch(imageQuote);
  const blob = await response.blob();

  let pageTitle = 'THe Page';
  let pageText  = document.getElementsByClassName("quote")[0].innerText;
  let pageUrl   = window.location.href; 
    
  const filesArray = [
    new File(
      [blob],
      'panion.jpg',
      {
        type: blob.type,
        lastModified: new Date().getTime()
      }
   )
  ];
  const shareData = {
    title: pageTitle,
    text: pageText,
    url: pageUrl,
    files: filesArray,
};
  if (navigator.share) {
  navigator
    .share(shareData)
    .then(() => console.log("Successful share"))
    .catch((error) => console.log("Error sharing", error));
} else {
  console.error("Browser doesn't support Web Share API");
}
    console.log(shareData);
}
    
function shareThisQuote() {
    return share();
}

`

0

There are 0 best solutions below