Advertisement
jargon

Roe2Js :: "files.js >> fileExists ( )"

Jun 26th, 2024
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Function to check if a file exists using a HEAD request
  2. function fileExists(url) {
  3.     try {
  4.         const response = fetch(url, { method: 'HEAD' });
  5.         return response.ok;
  6.     } catch (error) {
  7.         // console.error(`Error checking file existence: ${error}`);
  8.         return false;
  9.     }
  10. }
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement