fix: tolerate blank creative job requests
This commit is contained in:
@@ -378,9 +378,18 @@ export async function generateCreativeCopy(body: {
|
||||
}
|
||||
|
||||
export async function createCreativeImageJob(file?: File | null): Promise<Job> {
|
||||
const fd = new FormData()
|
||||
if (file) fd.append("file", file)
|
||||
const res = await fetch(`${API_BASE}/creative/jobs/image`, { method: "POST", body: fd })
|
||||
const init: RequestInit = file
|
||||
? (() => {
|
||||
const fd = new FormData()
|
||||
fd.append("file", file)
|
||||
return { method: "POST", body: fd }
|
||||
})()
|
||||
: {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: "{}",
|
||||
}
|
||||
const res = await fetch(`${API_BASE}/creative/jobs/image`, init)
|
||||
if (!res.ok) {
|
||||
const txt = await res.text().catch(() => "")
|
||||
throw apiError("createCreativeImageJob", res.status, txt)
|
||||
|
||||
Reference in New Issue
Block a user