From e9a2a561cf90e4fd15c9f9f51b4eae871a469362 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 19 May 2025 19:58:56 +0200 Subject: [PATCH] fetchApi.tsx fix nullable content-body for postData and wrapper --- tranga-website/src/api/fetchApi.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tranga-website/src/api/fetchApi.tsx b/tranga-website/src/api/fetchApi.tsx index 94aebc9..26c23d8 100644 --- a/tranga-website/src/api/fetchApi.tsx +++ b/tranga-website/src/api/fetchApi.tsx @@ -6,7 +6,7 @@ export function getData(uri: string) : Promise { return makeRequestWrapper("GET", uri, null); } -export function postData(uri: string, content: object | string | number | boolean) : Promise { +export function postData(uri: string, content?: object | string | number | boolean | null) : Promise { return makeRequestWrapper("POST", uri, content); } @@ -22,7 +22,7 @@ export function putData(uri: string, content: object | string | number | boolean return makeRequestWrapper("PUT", uri, content); } -function makeRequestWrapper(method: string, uri: string, content: object | string | number | null | boolean) : Promise{ +function makeRequestWrapper(method: string, uri: string, content?: object | string | number | null | boolean) : Promise{ return makeRequest(method, uri, content) .then((result) => result as Promise) .catch((e) => { @@ -32,7 +32,7 @@ function makeRequestWrapper(method: string, uri: string, content: object | strin } let currentlyRequestedEndpoints: string[] = []; -function makeRequest(method: string, uri: string, content: object | string | number | null | boolean) : Promise { +function makeRequest(method: string, uri: string, content?: object | string | number | null | boolean) : Promise { const id = method + uri; if(currentlyRequestedEndpoints.find(x => x == id) != undefined) return Promise.reject(`Already requested: ${method} ${uri}`);