mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: don't send Content-Type: application/json with empty POST body
This commit is contained in:
@@ -82,10 +82,12 @@ export async function apiGet<T>(path: string): Promise<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function apiPost<T>(path: string, body?: unknown): Promise<T> {
|
export async function apiPost<T>(path: string, body?: unknown): Promise<T> {
|
||||||
|
const headers =
|
||||||
|
body !== undefined ? formatHeaders({ "Content-Type": "application/json" }) : formatHeaders();
|
||||||
const res = await fetch(`${API_BASE}${path}`, {
|
const res = await fetch(`${API_BASE}${path}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: formatHeaders({ "Content-Type": "application/json" }),
|
headers,
|
||||||
body: body ? JSON.stringify(body) : undefined,
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
||||||
});
|
});
|
||||||
if (!res.ok) await throwWithMessage(res);
|
if (!res.ok) await throwWithMessage(res);
|
||||||
return res.json();
|
return res.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user