aboutsummaryrefslogtreecommitdiff
path: root/pages/testing.js
blob: 7540093aa9eeea239ac46946d57f138e78e79593 (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
35
36
import { signIn, signOut, useSession } from "next-auth/react";

export default function Testing() {
  const { data: session, status } = useSession();
  async function handleUpdate() {
    const lastPlayed = {
      id: "apahisya",
      time: 812989929,
    };
    const res = await fetch("/api/watched-episode", {
      method: "POST",
      body: JSON.stringify({
        username: session?.user.name,
        id: 150672,
        newData: lastPlayed,
      }),
      headers: {
        "Content-Type": "application/json",
      },
    });
    // const data = await res.json(); // parse the response body as JSON
    // console.log(data.dat.id);
    console.log(res.status);
  }

  console.log(session);
  return (
    <div>
      <button onClick={() => handleUpdate()}>Click for update</button>
      {!session && (
        <button onClick={() => signIn("AniListProvider")}>LOGIN</button>
      )}
      {session && <button onClick={() => signOut()}>LOGOUT</button>}
    </div>
  );
}