rsnext/examples/with-supertokens/app/components/callApiButton.tsx
Rishabh Poddar 91444dfef8
Fixes with-supertokens example (#65267)
This PR fixes how a protected API is called once the user is logged in,
in the `with-supertokens` example app.

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-02 19:19:20 +00:00

17 lines
385 B
TypeScript

"use client";
import styles from "../page.module.css";
export const CallAPIButton = () => {
const fetchUserData = async () => {
const userInfoResponse = await fetch("http://localhost:3000/api/user");
alert(JSON.stringify(await userInfoResponse.json()));
};
return (
<div onClick={fetchUserData} className={styles.sessionButton}>
Call API
</div>
);
};