Skip to content

getServerSideProps not working and throws error on dev #11259

Answered by ekafyi
ekafyi asked this question in Help
Discussion options

You must be logged in to vote

UPDATE: Nevermind, it's my .then Promise that's somehow botched 🤦🏽‍♀️. Fixed it by using await like the official docs example.

export async function getServerSideProps() {
  const posts = await fetch(endpoint);
  const json = await posts.json();
  if (json.results) {
    return {
      props: { posts: json.results }
    };
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Janpot
Comment options

Answer selected by ekafyi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants