We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples/_official-jokes/app/utils/session.server.ts
Line 93 in c825d9d
I got to this step: https://remix.run/docs/en/1.18.1/tutorials/jokes#expected-errors
work around was this: in session.server.ts
export async function getUser(request: Request) { const userId = await getUserId(request); if (typeof userId !== "string") { return null; } const user = await db.user.findUnique({ select: { id: true, username: true }, where: { id: userId }, }); if (!user) { return logout(request); } return user;
and this in jokes.tsx
export const loader = async ({ request }: LoaderArgs) => { const jokeListItems = await db.joke.findMany({ orderBy: { createdAt: "desc" }, select: { id: true, name: true }, take: 5, }); const user = await getUser(request); if(user instanceof Response){ throw user; } return json({ jokeListItems, user }); };
Very new to Remix, but this caught me a bit suprised, that it wouldn't result in redirect, because it was wrapped with async / await
The text was updated successfully, but these errors were encountered:
{ "private": true, "sideEffects": false, "scripts": { "build": "remix build", "dev": "remix dev", "start": "remix-serve build", "typecheck": "tsc" }, "dependencies": { "@prisma/client": "^4.16.2", "@remix-run/css-bundle": "^1.18.1", "@remix-run/node": "^1.18.1", "@remix-run/react": "^1.18.1", "@remix-run/serve": "^1.18.1", "bcryptjs": "^2.4.3", "isbot": "^3.6.8", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { "@remix-run/dev": "^1.18.1", "@remix-run/eslint-config": "^1.18.1", "@types/bcryptjs": "^2.4.2", "@types/react": "^18.0.35", "@types/react-dom": "^18.0.11", "eslint": "^8.38.0", "prisma": "^4.16.2", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.0.4" }, "engines": { "node": ">=14.0.0" }, "prisma": { "seed": "ts-node --require tsconfig-paths/register prisma/seed.ts" } }
Sorry, something went wrong.
Okay found another "workaround" which is probably more correct: throw await logout(request);
getUser
Successfully merging a pull request may close this issue.
examples/_official-jokes/app/utils/session.server.ts
Line 93 in c825d9d
I got to this step:
https://remix.run/docs/en/1.18.1/tutorials/jokes#expected-errors
Ended up with an app error, but expected to be redirected to "login" page instead.
work around was this:
in session.server.ts
and this in jokes.tsx
Very new to Remix, but this caught me a bit suprised, that it wouldn't result in redirect, because it was wrapped with async / await
The text was updated successfully, but these errors were encountered: