aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/EventReportPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/reports/EventReportPage.js')
-rw-r--r--modern/src/reports/EventReportPage.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js
index 4134de3d..fce9597f 100644
--- a/modern/src/reports/EventReportPage.js
+++ b/modern/src/reports/EventReportPage.js
@@ -25,19 +25,19 @@ const EventReportPage = () => {
const classes = useStyles();
const [data, setData] = useState([]);
- const handleSubmit = (deviceId, from, to) => {
+ const handleSubmit = async (deviceId, from, to) => {
const query = new URLSearchParams({
deviceId,
from: from.toISOString(),
to: to.toISOString(),
});
- fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } })
- .then((response) => {
- if (response.ok) {
- response.json().then(setData);
- }
- });
+ const response = await fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } })
+
+ if(response.ok) {
+ const data = await response.json();
+ setData(data);
+ }
}
return (