Created
November 11, 2021 20:19
-
-
Save PavlikPolivka/f6025705492c96396c3d94c8fc23cc8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blog.getInitialProps = async ({ query }) => { | |
const page = query.page || 1; //if page empty we request the first page | |
const response = await fetch(`${server}/api/posts/${page}`) | |
const posts = await response.json() | |
return { | |
totalCount: posts.totalCount, | |
pageCount: posts.pageCount, | |
currentPage: posts.currentPage, | |
perPage: posts.perPage, | |
posts: posts.posts, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment