Route loading infinitely
Unanswered
Ragdoll posted this in #help-forum
RagdollOP
I have a simple route to get all blog from db .
From Next Js I am using fetch , the backend is hosted on express which is calling the DB . Using console.log I can see the data is already fetched . But the routing is loading infinitely and not being responsive
This is the code for
From Next Js I am using fetch , the backend is hosted on express which is calling the DB . Using console.log I can see the data is already fetched . But the routing is loading infinitely and not being responsive
This is the code for
/blog
import type { Metadata } from "next";
import getAllBlogs from "../utils/getAllBlogs";
import Link from "next/link";
export const metadata: Metadata = {
title: "Blogs",
description: "List of all blogs written by Tjsm",
};
type Props = {};
async function getData() {
try {
const res = await getAllBlogs();
return res;
} catch (err) {
throw err;
}
}
async function Blog({}: Props) {
const res = await getData();
console.log("found blogs");
return (
<div>
{res?.length == 0
? "No blog"
: res?.map((b: Blog) => (
<div key={b._id}>
<Link href={`/blog/${b._id}`}> {b.title} </Link>
</div>
))}
</div>
);
}
export default Blog;