I am using NextJS and MongoDB (using Mongoose).
This is my Server Component:
import {
getPosts
} from "@/lib/mongoDb/post";
import PostsClientComponent from "./PostsClientComponent";
const fetchPosts = async () => {
let posts = await getPosts();
return posts;
};
export default async function Page() {
const posts = await fetchPosts();
return (
<PostsClientComponent
posts={posts}
/>
);
}
And this is my function getPosts()
export async function getPosts(){
dbConnect()
try
let posts = await Post.find();
return posts
}
catch(err){
console.log(err.message)
return false;
}
}
After running my webapp in dev I get a lot of warning messages:
This error is driving me crazy!!