chore: use RequestBody for everything else

This commit is contained in:
swve 2023-02-04 16:32:29 +01:00
parent ab96e34029
commit 6e037538af
5 changed files with 23 additions and 155 deletions

View file

@ -1,4 +1,5 @@
import { getAPIUrl } from "@services/config";
import { RequestBody } from "./utils/requests";
/*
This file includes only POST, PUT, DELETE requests
@ -6,49 +7,19 @@ import { getAPIUrl } from "@services/config";
*/
export async function createNewOrganization(body: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "POST",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
body: JSON.stringify(body),
};
return fetch(`${getAPIUrl()}orgs/`, requestOptions)
return fetch(`${getAPIUrl()}orgs/`, RequestBody("POST", body))
.then((result) => result.json())
.catch((error) => console.log("error", error));
}
export async function deleteOrganizationFromBackend(org_id: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "DELETE",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
};
return fetch(`${getAPIUrl()}orgs/${org_id}`, requestOptions)
return fetch(`${getAPIUrl()}orgs/${org_id}`, RequestBody("DELETE", null))
.then((result) => result.json())
.catch((error) => console.log("error", error));
}
export async function getOrganizationContextInfo(org_slug : any){
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "GET",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
};
return fetch(`${getAPIUrl()}orgs/slug/${org_slug}`, requestOptions)
export async function getOrganizationContextInfo(org_slug: any) {
return fetch(`${getAPIUrl()}orgs/slug/${org_slug}`, RequestBody("GET", null))
.then((result) => result.json())
.catch((error) => console.log("error", error));
}
}