getEvents api function

This commit is contained in:
mmacierzanka committed 2021-10-02 22:49:43 +02:00
1 parent 2217fb2634
commit 3632500387
1 file changed
+8
+8
View File
@@ -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;
};