Archived
fixed infinite query loop
This commit is contained in:
1 parent
78a2308ca6
commit
bc7cbfe11c
1 file changed
+12
-10
+12
-10
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Stack } from "react-bootstrap";
|
import { Stack } from "react-bootstrap";
|
||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@@ -7,15 +7,17 @@ import { BACKEND_URL } from "../../constants";
|
|||||||
export const Home = () => {
|
export const Home = () => {
|
||||||
const [events, updateEvents] = useState([]);
|
const [events, updateEvents] = useState([]);
|
||||||
|
|
||||||
axios
|
useEffect(() => {
|
||||||
.get(`${BACKEND_URL}/api/getEvents`)
|
axios
|
||||||
.then((res) => {
|
.get(`${BACKEND_URL}/api/getEvents`)
|
||||||
if (res.status !== 200) throw new Error(`Request failed with code ${res.status}: ${res.statusText}`);
|
.then((res) => {
|
||||||
updateEvents(res.data);
|
if (res.status !== 200) throw new Error(`Request failed with code ${res.status}: ${res.statusText}`);
|
||||||
})
|
updateEvents(res.data);
|
||||||
.catch((e) => {
|
})
|
||||||
console.error(`Failed to fetch events. ${e}`);
|
.catch((e) => {
|
||||||
});
|
console.error(`Failed to fetch events. ${e}`);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.con}>
|
<div className={styles.con}>
|
||||||
|
|||||||
Reference in new issue
Block a user