mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
- changed env to not go through proxy - some logging states need updates to accommodate the change Co-authored-by: wil <wil@storyteller.ai>
30 lines
665 B
TypeScript
30 lines
665 B
TypeScript
const MakeMultipartRequest = (endpoint = "", body: any) => {
|
|
const formData = new FormData();
|
|
|
|
Object.keys(body).forEach((key) => formData.append(key, body[key]));
|
|
|
|
formData.append("source", "file");
|
|
|
|
return fetch(`https://api.storyteller.ai${endpoint}`, {
|
|
method: "POST",
|
|
credentials: "include",
|
|
headers: {
|
|
Accept: "application/json",
|
|
},
|
|
body: formData,
|
|
})
|
|
.then((res) => res.json())
|
|
.then((res) => {
|
|
if (res && res.success) {
|
|
return res;
|
|
} else {
|
|
return { success: false };
|
|
}
|
|
})
|
|
.catch((e) => {
|
|
return { success: false };
|
|
});
|
|
};
|
|
|
|
export default MakeMultipartRequest;
|