aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Janzen <jjanzenn@proton.me>2024-04-28 15:42:23 -0500
committerJacob Janzen <jjanzenn@proton.me>2024-04-28 15:42:23 -0500
commitd843b6051a790d870f021c2f1c60eeebd93ae1b6 (patch)
tree9b835e0322b66ae266c03cc0611731777f7ec4bf
parent5d7c1b955b4d7632f667b9d28e6dfcebc2e1dbec (diff)
try fetch api
-rw-r--r--scripts/webring.js15
1 files changed, 3 insertions, 12 deletions
diff --git a/scripts/webring.js b/scripts/webring.js
index 2b08b77..07e5990 100644
--- a/scripts/webring.js
+++ b/scripts/webring.js
@@ -1,12 +1,3 @@
-const xhr = new XMLHttpRequest();
-
-xhr.open("GET", "https://aidang.cc/webring/all")
-xhr.send();
-xhr.responseType("json");
-xhr.onload = () => {
- if (xhr.readyState == 4 && xhr.status == 200) {
- console.log(xhr.response);
- } else {
- console.log(`Error: ${xhr.status}`);
- }
-}
+fetch("https://aidang.cc/webring/all", {
+ method: "GET"
+}).then((response) => response.json()).then((json) => console.log(json));