JavaScript Tips: Web share Api

const shareData = {
title: "au.mirza",
url: "https://www.instagram.com/au.mirza"
};
const btn = document.getElementById("share");
btn.addEventListener("click", shareHandler);
function shareHandler() {
if (navigator.share && navigator.canShare(shareData)) {
navigator
.share(shareData)
.then(alert("Thankyou for sharing."))
.catch(webConsole);
} else {
webConsole(
"Either your browser is incompatible or the data is not shareable"
);
}
}
Compatibility

Preview
This preview is taken from Edge running on Android 11.


![Troubleshooting [zsh: Corrupt History File]: A Simple Guide for Windows, Linux, macOS](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fstock%2Funsplash%2FxbEVM6oJ1Fs%2Fupload%2F160b183e50d491e945ca5ecb02f01896.jpeg&w=3840&q=75)

