forked from innovacion/Mayacontigo
17 lines
392 B
TypeScript
17 lines
392 B
TypeScript
export async function httpRequest(
|
|
method: string,
|
|
endpoint: string,
|
|
body: object | null,
|
|
) {
|
|
const url = "/api" + endpoint;
|
|
const data = {
|
|
method: method,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(body),
|
|
credentials: "include" as RequestCredentials,
|
|
};
|
|
return await fetch(url, data).then((response) => response.json());
|
|
}
|