Removed Duplicate API calls and Hardcoded test user data#186
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request integrates user authentication into the home route by adding a loader that fetches user data and replaces hardcoded profile information with dynamic values. It also corrects several API endpoint paths by removing redundant '/api' segments. Feedback was provided regarding the loader's error handling, suggesting that it should specifically check for 401 status codes for redirects while allowing other errors to be handled by an ErrorBoundary.
|
|
||
| export async function loader({ request }: LoaderFunctionArgs) { | ||
| const res = await requireUser(request); | ||
| if (res.status !== 200) throw redirect("/login"); |
There was a problem hiding this comment.
Redirecting to /login for any non-200 status code might be misleading if the server returns a 500 error. It is better to only redirect on 401 (Unauthorized) and handle other errors (like 500) by allowing the loader to throw an error that can be caught by an ErrorBoundary.
| if (res.status !== 200) throw redirect("/login"); | |
| if (res.status === 401) throw redirect("/login"); | |
| if (res.status !== 200) throw new Response("Failed to load user data", { status: res.status }); |
|
he is not a maintainer in this repo @Unmesh100 |
Bug #1 — Duplicate /api/api/ in projects list API call
Bug #2 — Duplicate /api/api/ in timeline save API call
Bug #3 — Hardcoded test user instead of real user data
the session.
useLoaderData to get real user data (user.name, user.email, user.avatar_url).