mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
chore: use RequestBody for everything else
This commit is contained in:
parent
ab96e34029
commit
6e037538af
5 changed files with 23 additions and 155 deletions
|
|
@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue