Skip to content

Commit

Permalink
move psn profile route and setup for /profile routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartaithan committed May 15, 2023
1 parent 15f9f62 commit bcf6f76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const getPSNProfile = async (
}

try {
const url = `${API_URL}/auth/profile`;
const url = `${API_URL}/profile/psn`;
const response = await fetch(url, {
method: "GET",
credentials: "include",
Expand Down
24 changes: 24 additions & 0 deletions pages/api/profile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { type NextApiHandler } from "next";

const getProfile: NextApiHandler = async (req, res) => {
return res.status(200).json({ message: "GET: Hello World!" });
};

const updateProfile: NextApiHandler = async (req, res) => {
return res.status(200).json({ message: "PUT: Hello World!" });
};

const handler: NextApiHandler = async (req, res) => {
const { method = "[Not Found]" } = req;
switch (method) {
case "GET":
return getProfile(req, res);
case "PUT":
return updateProfile(req, res);
default:
res.setHeader("Allow", ["GET", "PUT"]);
return res.status(405).end(`Method ${method} Not Allowed`);
}
};

export default handler;
File renamed without changes.
2 changes: 1 addition & 1 deletion providers/ProfileProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ProfileProvider: FC<IProfileProvider> = (props) => {
const user = useUser();

const updatePSNProfile = (): void => {
API.get("/auth/profile")
API.get("/profile/psn")
.then(({ data }) => {
const psn_profile = data.profile;
setProfiles((prev) => ({ ...prev, psn: psn_profile }));
Expand Down

0 comments on commit bcf6f76

Please sign in to comment.