aboutsummaryrefslogtreecommitdiff
path: root/pages/testing.js
blob: ffa808056feb539fb0fbd4fdbcea660234c6f98e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { getUser } from "./api/getUser";

export default function Testing({ user }) {
  async function handleUpdate() {
    const res = await fetch("/api/update-user", {
      method: "POST",
      body: JSON.stringify({
        name: "Factiven",
        newData: {
          settings: {
            tracking: false,
          },
        },
      }),
      headers: {
        "Content-Type": "application/json",
      },
    });
    console.log(res.status);
  }

  console.log(user.settings);
  return <button onClick={() => handleUpdate()}>Click for update</button>;
}

export async function getServerSideProps(context) {
  const user = await getUser("Factiven");
  console.log(user);
  return {
    props: {
      user: user,
    },
  };
}