mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 19:03:47 +00:00
event API refract
using optimistic updates
This commit is contained in:
@@ -1,8 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { serverURL } from './apiConstants';
|
||||
export const eventsURL = serverURL + 'events';
|
||||
export const eventsNamespace = 'events';
|
||||
export const eventsURL = serverURL + eventsNamespace;
|
||||
|
||||
export const fetchAllEvents = async () => {
|
||||
const res = await fetch(eventsURL);
|
||||
// TODO: Safe json convert
|
||||
return res.json();
|
||||
};
|
||||
const res = await axios.get(eventsURL);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const requestPost = async (data) => {
|
||||
const res = await axios.post(eventsURL, data);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const requestPut = async (data) => {
|
||||
const res = await axios.put(eventsURL, data);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const requestPatch = async (data) => {
|
||||
const res = await axios.patch(eventsURL, data);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const requestDelete = async (eventId) => {
|
||||
const res = await axios.delete(eventsURL + '/' + eventId);
|
||||
return res;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user