fixes profile avatar upload

This commit is contained in:
Christian Beutel
2024-03-20 13:52:32 +01:00
parent 2732aaf9c1
commit 3e8fb85c05
3 changed files with 43 additions and 14 deletions

View File

@@ -0,0 +1,13 @@
import { pb } from "$lib/pocketbase";
import type { User } from "$lib/stores/user_store";
import { error, json, type RequestEvent } from "@sveltejs/kit";
export async function POST(event: RequestEvent) {
const data = await event.request.formData()
try {
const r = await pb.collection("users").update<User>(event.params.id as string, data,);
return json(r);
} catch (e: any) {
throw error(e.status, e)
}
}