diff --git a/client/src/api/Api.ts b/client/src/api/Api.ts index 4924086..a8666b6 100644 --- a/client/src/api/Api.ts +++ b/client/src/api/Api.ts @@ -63,7 +63,7 @@ async function blobRequest( export const api = { get: (url: string) => request(url), blobGet: (url: string) => blobRequest(url), - post: (url: string, body: TBody) => request(url, { method: 'POST', body, headers: { 'Content-Type': 'application/json' } }), + post: (url: string, body?: TBody) => request(url, { method: 'POST', body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } }), } export const getQrUrl = (login: string) => { @@ -79,5 +79,5 @@ export const getData = async (dayIndex?: number) => { } export const login = async (login?: string) => { - return await api.post('/api/login', JSON.stringify({ login })); + return await api.post('/api/login', { login }); } diff --git a/client/src/api/FoodApi.ts b/client/src/api/FoodApi.ts index ad19d80..26241a2 100644 --- a/client/src/api/FoodApi.ts +++ b/client/src/api/FoodApi.ts @@ -3,25 +3,25 @@ import { api } from "./Api"; const FOOD_API_PREFIX = '/api/food'; export const addChoice = async (locationIndex: number, foodIndex?: number, dayIndex?: number) => { - return await api.post(`${FOOD_API_PREFIX}/addChoice`, JSON.stringify({ locationIndex, foodIndex, dayIndex })); + return await api.post(`${FOOD_API_PREFIX}/addChoice`, { locationIndex, foodIndex, dayIndex }); } export const removeChoices = async (locationIndex: number, dayIndex?: number) => { - return await api.post(`${FOOD_API_PREFIX}/removeChoices`, JSON.stringify({ locationIndex, dayIndex })); + return await api.post(`${FOOD_API_PREFIX}/removeChoices`, { locationIndex, dayIndex }); } export const removeChoice = async (locationIndex: number, foodIndex: number, dayIndex?: number) => { - return await api.post(`${FOOD_API_PREFIX}/removeChoice`, JSON.stringify({ locationIndex, foodIndex, dayIndex })); + return await api.post(`${FOOD_API_PREFIX}/removeChoice`, { locationIndex, foodIndex, dayIndex }); } export const updateNote = async (note?: string, dayIndex?: number) => { - return await api.post(`${FOOD_API_PREFIX}/updateNote`, JSON.stringify({ note, dayIndex })); + return await api.post(`${FOOD_API_PREFIX}/updateNote`, { note, dayIndex }); } export const changeDepartureTime = async (time: string, dayIndex?: number) => { - return await api.post(`${FOOD_API_PREFIX}/changeDepartureTime`, JSON.stringify({ time, dayIndex })); + return await api.post(`${FOOD_API_PREFIX}/changeDepartureTime`, { time, dayIndex }); } export const jdemeObed = async () => { - return await api.post(`${FOOD_API_PREFIX}/jdemeObed`, JSON.stringify({})); + return await api.post(`${FOOD_API_PREFIX}/jdemeObed`, undefined); } diff --git a/client/src/api/PizzaDayApi.ts b/client/src/api/PizzaDayApi.ts index fffdcfb..89ede1e 100644 --- a/client/src/api/PizzaDayApi.ts +++ b/client/src/api/PizzaDayApi.ts @@ -24,21 +24,21 @@ export const finishOrder = async () => { } export const finishDelivery = async (bankAccount?: string, bankAccountHolder?: string) => { - return await api.post(`${PIZZADAY_API_PREFIX}/finishDelivery`, JSON.stringify({ bankAccount, bankAccountHolder })); + return await api.post(`${PIZZADAY_API_PREFIX}/finishDelivery`, { bankAccount, bankAccountHolder }); } export const addPizza = async (pizzaIndex: number, pizzaSizeIndex: number) => { - return await api.post(`${PIZZADAY_API_PREFIX}/add`, JSON.stringify({ pizzaIndex, pizzaSizeIndex })); + return await api.post(`${PIZZADAY_API_PREFIX}/add`, { pizzaIndex, pizzaSizeIndex }); } export const removePizza = async (pizzaOrder: PizzaOrder) => { - return await api.post(`${PIZZADAY_API_PREFIX}/remove`, JSON.stringify({ pizzaOrder })); + return await api.post(`${PIZZADAY_API_PREFIX}/remove`, { pizzaOrder }); } export const updatePizzaDayNote = async (note?: string) => { - return await api.post(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, JSON.stringify({ note })); + return await api.post(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, { note }); } export const updatePizzaFee = async (login: string, text?: string, price?: number) => { - return await api.post(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, JSON.stringify({ login, text, price })); + return await api.post(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, { login, text, price }); } diff --git a/client/src/api/VotingApi.ts b/client/src/api/VotingApi.ts index e215546..7a47c53 100644 --- a/client/src/api/VotingApi.ts +++ b/client/src/api/VotingApi.ts @@ -8,5 +8,5 @@ export const getFeatureVotes = async () => { } export const updateFeatureVote = async (option: FeatureRequest, active: boolean) => { - return await api.post(`${VOTING_API_PREFIX}/updateVote`, JSON.stringify({ option, active })); + return await api.post(`${VOTING_API_PREFIX}/updateVote`, { option, active }); } \ No newline at end of file