diff options
Diffstat (limited to 'webAO/utils/fileExists.js')
| -rw-r--r-- | webAO/utils/fileExists.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/webAO/utils/fileExists.js b/webAO/utils/fileExists.js index a4b3b80..5b60976 100644 --- a/webAO/utils/fileExists.js +++ b/webAO/utils/fileExists.js @@ -1,18 +1,18 @@ const fileExists = async (url) => new Promise((resolve) => { - const xhr = new XMLHttpRequest(); - xhr.open('HEAD', url); - xhr.onload = function checkLoad() { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - resolve(true); - } else { + const xhr = new XMLHttpRequest(); + xhr.open('HEAD', url); + xhr.onload = function checkLoad() { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + resolve(true); + } else { + resolve(false); + } + } + }; + xhr.onerror = function checkError() { resolve(false); - } - } - }; - xhr.onerror = function checkError() { - resolve(false); - }; - xhr.send(null); + }; + xhr.send(null); }); export default fileExists; |
