From dc208478fd18a4e28c0083641bf405170859fc58 Mon Sep 17 00:00:00 2001 From: "caleb.mabry.15@cnu.edu" Date: Thu, 10 Mar 2022 23:21:38 -0500 Subject: Magnum Opus pt1 --- webAO/utils/fileExists.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 webAO/utils/fileExists.js (limited to 'webAO/utils/fileExists.js') diff --git a/webAO/utils/fileExists.js b/webAO/utils/fileExists.js new file mode 100644 index 0000000..261acda --- /dev/null +++ b/webAO/utils/fileExists.js @@ -0,0 +1,17 @@ +const fileExists = async (url) => { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.onload = function (e) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + return true; + } + return false; + } + }; + xhr.onerror = function (e) { + return false; + }; + xhr.send(null); +}; +export default fileExists; -- cgit