admin管理员组

文章数量:1122832

Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

'user server'
    import { sql } from "@vercel/postgres";
    
    const TodosPage = async () => {
    const rows = await sql`
        SELECT id, text, done FROM todos
        ORDER BY id
      `;
      console.log(rows);
    
      return (
        <div className="p-4">
          <h1 className="text-xl font-bold">To-Do List</h1>
          <ul className="mt-4 space-y-2">
            test
          </ul>
        </div>
      );
    };
    
    export default TodosPage;

I cant display with nextjs on the server side what I see in the database. Apparently because of its async property

Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

'user server'
    import { sql } from "@vercel/postgres";
    
    const TodosPage = async () => {
    const rows = await sql`
        SELECT id, text, done FROM todos
        ORDER BY id
      `;
      console.log(rows);
    
      return (
        <div className="p-4">
          <h1 className="text-xl font-bold">To-Do List</h1>
          <ul className="mt-4 space-y-2">
            test
          </ul>
        </div>
      );
    };
    
    export default TodosPage;

I cant display with nextjs on the server side what I see in the database. Apparently because of its async property

Share Improve this question asked Nov 22, 2024 at 16:01 Hugo Del-NegroHugo Del-Negro 1434 silver badges13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

using a try cache got the error

VercelPostgresError: VercelPostgresError - 'missing_connection_string': You did not supply a 'connectionString' and no 'POSTGRES_URL' env var was found..

It seems postGres is not properly configured. Fixed it and apparently the issue is still there

Found the answer https://github.com/vercel/next.js/discussions/52336 is was using pages router instead of app router

本文标签: nextjsSSR Objects are not valid as a React child nextjsStack Overflow