From 36325003873e1a2860a8b76b0c68dbf251433fcb Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Sat, 2 Oct 2021 22:49:43 +0200 Subject: [PATCH] getEvents api function --- src/utils/api/getEvents.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/utils/api/getEvents.js diff --git a/src/utils/api/getEvents.js b/src/utils/api/getEvents.js new file mode 100644 index 0000000..823cccc --- /dev/null +++ b/src/utils/api/getEvents.js @@ -0,0 +1,8 @@ +import axios from "axios"; +import { BACKEND_URL } from "../../constants"; + +export const getEvents = async () => { + const rq = await axios.get(`${BACKEND_URL}/api/getEvents`); + if (rq.status !== 200) throw new Error(`Request failed with code ${rq.status}: ${rq.statusText}`); + return rq.data; +};