blob: e125e047efa08261b1f2c2cd4216cadd8c316fa4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import { fail, redirect } from "@sveltejs/kit";
import { fd, auth, post } from "$lib/utils";
export const actions = {
default: async ({ cookies, request, url }) => {
const form = await fd(request);
try {
await post("/items", form, auth(cookies));
} catch (e: any) {
return fail(400, { message: e.message });
}
const success = `/${url.pathname.split("/")[1]}`;
redirect(307, success);
},
};
|