Skip to content
Discussion options

You must be logged in to vote

Hey there! I will try to address each comment individually, let me know if you still have questions!

The first snippet you sent is correct, saving the file as pages/tst.js and accessing the page in http://localhost:3000/tst will return the correct result in the browser (data: test) and log getServerSideProps() in the terminal that you started the server.


The class snippet with getInitialProps doesn't work because it is defining the function as a instance method, it must be a static method in order to be accessed like YourPage.getInitialProps (notice that we don't need to create an instance of the class to use the method). If you add the static keyword it will start logging getInitialProps

Replies: 7 comments 19 replies

Comment options

You must be logged in to vote
2 replies
@ekkis
Comment options

@ekkis
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@pavittarx
Comment options

@ekkis
Comment options

@pavittarx
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@pavittarx
Comment options

@ekkis
Comment options

Comment options

You must be logged in to vote
3 replies
@pavittarx
Comment options

@pavittarx
Comment options

@ekkis
Comment options

Comment options

You must be logged in to vote
9 replies
@rafaelalmeidatk
Comment options

@ekkis
Comment options

@ekkis
Comment options

@ekkis
Comment options

@ekkis
Comment options

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