aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/ecash/+page.server.js
blob: 8541a3f818511d22ae002df97a753d6d12aca14c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { fail, redirect } from "@sveltejs/kit";
import { auth, post, fd } from "$lib/utils";

export const actions = {
  default: async ({ cookies, request }) => {
    let token;
    try {
      let body = await fd(request);
      ({ token } = await post("/mint", body, auth(cookies)));
      console.log("token", token)
    } catch (e) {
      console.log(e)
      console.log("problem creating ecash", e);
      return fail(400, { message: e.message });
    }

    cookies.set("ecash", token, { path: "/" });

    console.log("redirecting")
    redirect(307, `/${cookies.get("username")}/ecash`);
  },
};