0
votes

I'm playing around with nextjs and I've trouble to debug a function like this:

export const authInitialProps = isProtectedRoute => {
  console.log("mylog");// this works 
  return ({ req, res }) => {
    console.log("inner my log", req); // this doesn't work
  };
};

Using in a page

ProfilePage.getInitialProps = async () => {
  const auth = authInitialProps(true);
  if (!typeof auth === "function") {
    const user = await getUserProfile();
    return { user };
  }
  return { user: null };
};

I never see "inner my log" both in chrome console and in my console terminal. What's the problem please?

1

1 Answers

1
votes

Try this It may work:

ProfilePage.getInitialProps = async () => {
  const auth = await authInitialProps(true); // await added
  if (!typeof auth === "function") {
    const user = await getUserProfile();
    return { user };
  }
  return { user: null };
};

I think it should be async to not pass over it!