Last active
January 27, 2023 05:11
-
-
Save shameemreza/32106d71aa40cf6d013551c1d7a48319 to your computer and use it in GitHub Desktop.
Example of Mastering the Art of Server-Side Rendering with Next.js
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
import axios from 'axios' | |
const About = ({ data }) => { | |
return ( | |
<div> | |
<h1>About Our App</h1> | |
<p>Our app is the best thing since sliced bread.</p> | |
<p>Data from API: {data}</p> | |
</div> | |
) | |
} | |
About.getInitialProps = async () => { | |
const response = await axios.get('https://my-api.com/data') | |
return { data: response.data } | |
} | |
export default About |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment