小编sla*_*903的帖子

对象作为 React 子对象无效(找到:[object Promise])。如果您打算渲染子集合,请改用数组。ReactJS

“/pages/blog/index.js”中的代码:

import BlogComponents from "../../components/Blog/blogComponents";
import { listBlogs } from "../../server/mongodb";

const index = async (props) => {
  console.log(props)
  return (
    <div>
      <Head>
        <title>BLOG TITLE</title>
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <meta httpEquiv="Content-Type" content="text/html;charset=UTF-8" />
      </Head>
      <h1>BLOG HEADER</h1>
      <BlogComponents />
    </div>
  );
};

export async function getServerSideProps() {
  var blogs = await listBlogs();
  try {
    return {
      props: { blogs }
    }
  }
  catch (error) {
    console.log(error);
  }
}
export default index;
Run Code Online (Sandbox Code Playgroud)

“../../server/mongodb.js”中的代码:

import mongoose from "mongoose";
// …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs next.js

7
推荐指数
1
解决办法
9273
查看次数

标签 统计

javascript ×1

next.js ×1

reactjs ×1