diff options
Diffstat (limited to 'pages/testing.js')
| -rw-r--r-- | pages/testing.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/pages/testing.js b/pages/testing.js index ffa8080..cae165a 100644 --- a/pages/testing.js +++ b/pages/testing.js @@ -1,26 +1,38 @@ -import { getUser } from "./api/getUser"; +import { getUser } from "./api/get-user"; +import { useSession, signIn } from "next-auth/react"; export default function Testing({ user }) { + const { data: session } = useSession(); async function handleUpdate() { - const res = await fetch("/api/update-user", { + const lastPlayed = { + id: "apahisya", + time: 812989929, + }; + const res = await fetch("/api/watched-episode", { method: "POST", body: JSON.stringify({ - name: "Factiven", - newData: { - settings: { - tracking: false, - }, - }, + 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(user.settings); - return <button onClick={() => handleUpdate()}>Click for update</button>; + return ( + <div> + <button onClick={() => handleUpdate()}>Click for update</button> + {!session && ( + <button onClick={() => signIn("AniListProvider")}>LOGIN</button> + )} + </div> + ); } export async function getServerSideProps(context) { |