fix: Return POST resposne to the page
This commit is contained in:
parent
24257fea8c
commit
88558579d7
@ -7,10 +7,8 @@
|
||||
async function submit(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
if (files.length === 0) return;
|
||||
const success = await generateStream(files[0]);
|
||||
if (success) {
|
||||
// success feedback
|
||||
}
|
||||
const res = await generateStream(files[0]);
|
||||
console.log(res);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -1,16 +1,11 @@
|
||||
export async function generateStream(file: File): Promise<boolean> {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
export async function generateStream(file: File): Promise<Response> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
await fetch(`/api/set-profile-photo/`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
const res = await fetch(`/api/set-profile-photo/`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(`Error sending stream: ${(e as Error).message}`);
|
||||
return false;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user