This commit is contained in:
BennyKok 2023-12-15 20:27:24 +08:00
parent a484bb91fd
commit e8451c3749

View File

@ -65,26 +65,24 @@ export async function createRun(
status_endpoint: `${origin}/api/update-run`, status_endpoint: `${origin}/api/update-run`,
file_upload_endpoint: `${origin}/api/file-upload`, file_upload_endpoint: `${origin}/api/file-upload`,
}; };
console.log(body); // console.log(body);
const bodyJson = JSON.stringify(body); const bodyJson = JSON.stringify(body);
console.log(bodyJson); // console.log(bodyJson);
// Sending to comfyui // Sending to comfyui
const result = await fetch(comfyui_endpoint, { const _result = await fetch(comfyui_endpoint, {
method: "POST", method: "POST",
body: bodyJson, body: bodyJson,
cache: "no-store", cache: "no-store",
}) });
.then(async (res) => {
const text = await res.text(); if (!_result.ok) {
console.log(text); throw new Error(`Error creating run, ${_result.statusText}`);
return text; }
})
.then(async (res) => ComfyAPI_Run.parseAsync(JSON.parse(res))) console.log(_result);
.catch((err) => {
console.log("Some went wrong in parsing the response"); const result = await ComfyAPI_Run.parseAsync(await _result.json());
throw new Error(err);
});
console.log(result); console.log(result);