}
}, []);
- React.useEffect(() => {
- const controller = new AbortController();
+ const fetchEvents = React.useCallback((controller) => {
axios.get(`/api/events`, {
signal: controller.signal,
params: {
- after: moment().startOf('day').subtract(7, 'days').toISOString(),
+ after: moment().startOf('day').subtract(1, 'days').toISOString(),
before: moment().startOf('day').add(8, 'days').toISOString(),
},
}).then(response => {
console.error(e);
}
});
+ });
+
+ React.useEffect(() => {
+ const controller = new AbortController();
+ fetchEvents(controller);
+ const timer = setInterval(() => {
+ fetchEvents(controller);
+ clearInterval(timer);
+ }, 15 * 60 * 1000);
return () => {
controller.abort();
};