Skip to content

Commit 4e06942

Browse files
Prisma Postgres example updated
1 parent ba47a7c commit 4e06942

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

examples/prisma-postgres/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Once the server is running, visit `http://localhost:3000` to start using the app
232232

233233
The app includes the following routes:
234234

235-
- `/`: Display the thee most recent posts
235+
- `/`: Display the three most recent posts
236236
- `/posts`: Paginated list view of all posts
237237
- `/posts/new`: Create a new post
238238
- `/users/new`: Create a new user
@@ -242,7 +242,7 @@ The app includes the following routes:
242242

243243
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
244244

245-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fprisma-orm&env=DATABASE_URL&envDescription=Add%20your%20PRISMA%20POSTGRES%20database%20url&project-name=prisma-orm-app&repository-name=prisma-orm)
245+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fprisma-postgres&env=DATABASE_URL&envDescription=Add%20your%20PRISMA%20POSTGRES%20database%20url&project-name=prisma-postgres-app&repository-name=prisma-postgres)
246246

247247
## Additional information
248248

examples/prisma-postgres/app/posts/page.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,29 @@ function PostsList() {
2424
const [posts, setPosts] = useState<Post[]>([]);
2525
const [totalPages, setTotalPages] = useState(1);
2626
const [isLoading, setIsLoading] = useState(true);
27+
const [error, setError] = useState<string | null>(null);
2728

2829
useEffect(() => {
2930
async function fetchPosts() {
3031
setIsLoading(true);
32+
setError(null);
3133
try {
3234
const res = await fetch(`/api/posts?page=${page}`);
3335
if (!res.ok) {
34-
throw new Error("Failed to fetch posts");
36+
throw new Error(
37+
`Failed to fetch posts: ${res.status} ${res.statusText}`,
38+
);
3539
}
3640
const data = await res.json();
3741
setPosts(data.posts);
3842
setTotalPages(data.totalPages);
3943
} catch (error) {
4044
console.error("Error fetching posts:", error);
45+
setError(
46+
error instanceof Error
47+
? error.message
48+
: "An unexpected error occurred",
49+
);
4150
} finally {
4251
setIsLoading(false);
4352
}
@@ -53,6 +62,19 @@ function PostsList() {
5362
<div className="w-6 h-6 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"></div>
5463
<p className="text-gray-600">Loading...</p>
5564
</div>
65+
) : error ? (
66+
<div className="flex flex-col items-center justify-center min-h-[200px] space-y-4">
67+
<div className="text-red-500 text-center">
68+
<p className="text-lg font-semibold">Failed to load posts</p>
69+
<p className="text-sm text-gray-600 mt-1">{error}</p>
70+
</div>
71+
<button
72+
onClick={() => window.location.reload()}
73+
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
74+
>
75+
Try Again
76+
</button>
77+
</div>
5678
) : (
5779
<>
5880
{posts.length === 0 ? (

examples/prisma-postgres/app/setup/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function SetupPage() {
7575
Prisma Postgres extension
7676
</a>{" "}
7777
in your Netlify account. Next, you need to copy Prisma&apos;s
78-
integration token into the extension in your Neltify Dashboard:
78+
integration token into the extension in your Netlify Dashboard:
7979
</p>
8080
<ol className="list-decimal pl-6 mt-2 space-y-1 text-gray-700">
8181
<li>

0 commit comments

Comments
 (0)