aboutsummaryrefslogtreecommitdiff
path: root/src/useFetch.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/useFetch.js')
-rw-r--r--src/useFetch.js17
1 files changed, 0 insertions, 17 deletions
diff --git a/src/useFetch.js b/src/useFetch.js
deleted file mode 100644
index d098e2f..0000000
--- a/src/useFetch.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { useEffect, useState } from "react";
-
-export default function useFetch(url, options) {
- const [data, setData] = useState(null);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- fetch(url, options)
- .then((resp) => resp.json())
- .then((resp) => setData(resp))
- .catch((err) => setError(err))
- .finally(() => setLoading(false));
- }, []);
-
- return { data, loading, error };
-}