Fix POST without body: only set Content-Type when body present
This commit is contained in:
parent
32318aa63f
commit
fc92bcd897
1 changed files with 2 additions and 1 deletions
|
|
@ -3,9 +3,10 @@ import type { DeptActuals, DeptScheduled, NetSalesDay, WageBudget, AppSetting }
|
|||
const BASE = '/wages/api'
|
||||
|
||||
async function request<T>(path: string, opts: RequestInit = {}): Promise<T> {
|
||||
const headers: Record<string, string> = opts.body != null ? { 'Content-Type': 'application/json' } : {}
|
||||
const res = await fetch(`${BASE}${path}`, {
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json', ...opts.headers },
|
||||
headers: { ...headers, ...opts.headers },
|
||||
...opts,
|
||||
})
|
||||
if (res.status === 401) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue