Next.js Discord

Discord Forum

Async not working in my page function

Unanswered
Cinnamon posted this in #help-forum
Open in Discord
CinnamonOP
const TestPage = async () => {
  const session = await getServerSession(authOptions)
  
  return (...)
}
export async function getServerSideProps(context: any) {
    return {
        props: {
            ...await serverSideTranslations(context.locale, ['common']),
        },
    };
}
export default TestPage;


Is there anything went wrong with my code? I have the error below when run this code. When i removed the async then it works.

Server Error
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.

3 Replies