fix: Return POST resposne to the page

This commit is contained in:
April Hall 2025-02-22 02:44:16 -05:00
parent 24257fea8c
commit 88558579d7
Signed by: arithefirst
GPG Key ID: 4508A15C4DB91C5B
2 changed files with 10 additions and 17 deletions

View File

@ -7,10 +7,8 @@
async function submit(e: SubmitEvent) { async function submit(e: SubmitEvent) {
e.preventDefault(); e.preventDefault();
if (files.length === 0) return; if (files.length === 0) return;
const success = await generateStream(files[0]); const res = await generateStream(files[0]);
if (success) { console.log(res);
// success feedback
}
} }
</script> </script>

View File

@ -1,16 +1,11 @@
export async function generateStream(file: File): Promise<boolean> { export async function generateStream(file: File): Promise<Response> {
try {
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
await fetch(`/api/set-profile-photo/`, { const res = await fetch(`/api/set-profile-photo/`, {
method: 'POST', method: 'POST',
body: formData, body: formData,
}); });
return true; return res;
} catch (e) {
console.error(`Error sending stream: ${(e as Error).message}`);
return false;
}
} }