Skip to content

Commit

Permalink
Fixes with-supertokens example (#65267)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rishabhpoddar and samcx authored May 2, 2024
1 parent 2a2a4e7 commit 91444df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
8 changes: 1 addition & 7 deletions examples/with-supertokens/app/components/callApiButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
"use client";

import Session from "supertokens-auth-react/recipe/session";
import styles from "../page.module.css";

export const CallAPIButton = () => {
const fetchUserData = async () => {
const accessToken = await Session.getAccessToken();
const userInfoResponse = await fetch("http://localhost:3000/api/user", {
headers: {
Authorization: "Bearer " + accessToken,
},
});
const userInfoResponse = await fetch("http://localhost:3000/api/user");

alert(JSON.stringify(await userInfoResponse.json()));
};
Expand Down
3 changes: 1 addition & 2 deletions examples/with-supertokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"react": "^18",
"react-dom": "^18",
"supertokens-auth-react": "latest",
"supertokens-node": "latest",
"supertokens-web-js": "latest"
"supertokens-node": "latest"
},
"devDependencies": {
"@types/cookie": "^0.5.2",
Expand Down

0 comments on commit 91444df

Please sign in to comment.