Created the postRequest function in the RequestUtil.js

This commit is contained in:
Mathias Wagner 2023-06-02 21:28:31 +02:00
parent 34d775bf6f
commit f8d9e6c1f4
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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;
}
}