From f8d9e6c1f4e8d2c49f5af4bebbaf6e71650ce925 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Fri, 2 Jun 2023 21:28:31 +0200 Subject: [PATCH] Created the postRequest function in the RequestUtil.js --- client/src/common/utils/RequestUtil.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/common/utils/RequestUtil.js b/client/src/common/utils/RequestUtil.js index b4392f4..fd3bc5c 100644 --- a/client/src/common/utils/RequestUtil.js +++ b/client/src/common/utils/RequestUtil.js @@ -12,4 +12,13 @@ export const jsonRequest = async (path, headers = {}) => { } catch (e) { return null; } +} + +// Run a POST request and get the json of the response +export const postRequest = async (path, body = {}, headers = {}) => { + try { + return (await request(path, "POST", body, {...headers, "Content-Type": "application/json"})).json(); + } catch (e) { + return null; + } } \ No newline at end of file