while i was working in localhost my web share code is working perfectly but when i hosted my website same code stopped working. my code is still working in localhost server but not in hosted server.
this is my code:
<li class="post-menu-item share_btn" id="'.$post_id.'">Share</li>
actually it is written under php so it has id="'.$post_id.'" in it.
this is my web share API code:
$(".share_btn").click(function(e) {
const post_id = $(this).attr("id");
const link = 'http://localhost/hypeup/post/' + post_id + '/';
if (navigator.share) {
navigator.share({
title: 'My awesome post!',
text: 'This post may or may not contain the answer to the universe',
url: link,
}).then(() => {
console.log('Thanks for sharing!');
})
.catch(err => {
console.log(`Couldn't share because of`, err.message);
});
} else {
console.log('web share not supported');
}});