mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
remove Utils.apiPost
This commit is contained in:
parent
13b4b0e83d
commit
2395451b18
18
src/utils.ts
18
src/utils.ts
@ -331,24 +331,6 @@ export async function localPing() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function apiPost(path: string, data?: any, contentType: string = "application/json", authed: boolean = false): Promise<Response> {
|
|
||||||
return (isLocal && isLocalServerConnected) || !isLocal ? new Promise((resolve, reject) => {
|
|
||||||
const headers = {
|
|
||||||
"Accept": contentType,
|
|
||||||
"Content-Type": contentType,
|
|
||||||
};
|
|
||||||
if (authed) {
|
|
||||||
const sId = getCookie(sessionIdKey);
|
|
||||||
if (sId) {
|
|
||||||
headers["Authorization"] = sId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fetch(`${apiUrl}/${path}`, { method: "POST", headers: headers, body: data })
|
|
||||||
.then(response => resolve(response))
|
|
||||||
.catch(err => reject(err));
|
|
||||||
}) : new Promise(() => {});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Alias for the constructor of a class */
|
/** Alias for the constructor of a class */
|
||||||
export type Constructor<T> = new(...args: unknown[]) => T;
|
export type Constructor<T> = new(...args: unknown[]) => T;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user