Unverified Commit 91444dfe authored by Rishabh Poddar's avatar Rishabh Poddar Committed by GitHub

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: 's avatarSam Ko <sam@vercel.com>
parent 2a2a4e7c
"use client"; "use client";
import Session from "supertokens-auth-react/recipe/session";
import styles from "../page.module.css"; import styles from "../page.module.css";
export const CallAPIButton = () => { export const CallAPIButton = () => {
const fetchUserData = async () => { const fetchUserData = async () => {
const accessToken = await Session.getAccessToken(); const userInfoResponse = await fetch("http://localhost:3000/api/user");
const userInfoResponse = await fetch("http://localhost:3000/api/user", {
headers: {
Authorization: "Bearer " + accessToken,
},
});
alert(JSON.stringify(await userInfoResponse.json())); alert(JSON.stringify(await userInfoResponse.json()));
}; };
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",
"supertokens-auth-react": "latest", "supertokens-auth-react": "latest",
"supertokens-node": "latest", "supertokens-node": "latest"
"supertokens-web-js": "latest"
}, },
"devDependencies": { "devDependencies": {
"@types/cookie": "^0.5.2", "@types/cookie": "^0.5.2",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment