Added error message component. Update fetch hook.

This commit is contained in:
Mike Cao committed 2020-10-03 22:36:51 -07:00
1 parent 4cafa68e23
commit ca8a6fe049
8 files changed
+50 -11

No files matched your search

+7 -1
View File
@@ -25,7 +25,13 @@ export default function useFetch(url, params = {}, options = {}) {
dispatch(updateQuery({ url, time: performance.now() - time, completed: Date.now() }));
setData(data);
if (status >= 400) {
setError(data);
setData(null);
} else {
setData(data);
}
setStatus(status);
onDataLoad(data);
} catch (e) {