You've already forked agentic-coding-workflow
feat(web): chat + llmAdmin api clients with FormData support
This commit is contained in:
@@ -21,10 +21,11 @@ export function configure(opts: {
|
||||
}
|
||||
|
||||
export async function request<T>(path: string, opts: RequestOptions = {}): Promise<T> {
|
||||
const isForm = opts.body instanceof FormData
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Client-Request-ID': crypto.randomUUID(),
|
||||
}
|
||||
if (!isForm) headers['Content-Type'] = 'application/json'
|
||||
const token = authTokenProvider()
|
||||
if (token) headers['Authorization'] = `Bearer ${token}`
|
||||
|
||||
@@ -39,10 +40,16 @@ export async function request<T>(path: string, opts: RequestOptions = {}): Promi
|
||||
}
|
||||
|
||||
try {
|
||||
const body =
|
||||
opts.body === undefined
|
||||
? undefined
|
||||
: isForm
|
||||
? (opts.body as FormData)
|
||||
: JSON.stringify(opts.body)
|
||||
const resp = await fetch(BASE + path, {
|
||||
method: opts.method || 'GET',
|
||||
headers,
|
||||
body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
||||
body,
|
||||
signal: controller.signal,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user