aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/fileExists.js
diff options
context:
space:
mode:
authorcaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-10 23:21:38 -0500
committercaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-10 23:21:38 -0500
commitdc208478fd18a4e28c0083641bf405170859fc58 (patch)
tree1fad0ecbaf5639d02908b5f9c9f31f1878ee446c /webAO/utils/fileExists.js
parent6dd1b296c2dd1d7462dd8514dff43db59ac8dd19 (diff)
Magnum Opus pt1
Diffstat (limited to 'webAO/utils/fileExists.js')
-rw-r--r--webAO/utils/fileExists.js17
1 files changed, 17 insertions, 0 deletions
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;