0

I have this code to check if a url is from youtube or not, then use try catch to check if it valid in iframe - but the try catch didnt work I got this error:

The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.

any solution ? thanks

const s = document.getElementsByClassName("responsive-iframe")[0].src;
 async function youtubeshow(id)
{
  


if((document.getElementsByClassName("addlinkss")[0].value.slice(0,17)=='https://youtu.be/' && document.getElementsByClassName("addlinkss")[0].value.length==28)  )
{
  
    try {
 document.getElementsByClassName("responsive-iframe")[0].src='https://www.youtube.com/embed/'+document.getElementsByClassName("addlinkss")[0].value.slice(17);
}
catch(e){
  alert("ez");
$('#responsive-iframe').attr('src', s);
}
}else{
    document.getElementsByClassName("responsive-iframe")[0].src=s;
    console.log("no"+document.getElementsByClassName("addlinkss")[0].value.length);
 document.getElementsByClassName("addlinkss")[0].focus();
}

 
  
}
James Westgate
  • 11,306
  • 8
  • 61
  • 68
  • check https://stackoverflow.com/questions/66099180/react-js-error-the-service-worker-navigation-preload-request-was-cancelled-befo – James Sep 07 '22 at 19:51

0 Answers0