Files
artcraft/app/api/MakeMultipartRequest.ts
T
wilandwil a2c82badbc went through every file to rid of session token (#487)
- changed env to not go through proxy
- some logging states need updates to accommodate the change

Co-authored-by: wil <wil@storyteller.ai>
2024-06-17 21:55:01 -04:00

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;