Created
February 22, 2023 09:26
-
-
Save shameemreza/f7e78aa472f176f641779caba358d335 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
function UserProfile({ user }) { | |
return ( | |
<div> | |
<h1>{user.name}</h1> | |
<p>{user.bio}</p> | |
</div> | |
); | |
} | |
export async function getServerSideProps(context) { | |
const { slug } = context.query; | |
// Fetch data for user with slug | |
const res = await fetch(`https://api.example.com/users/${slug}`); | |
const user = await res.json(); | |
return { | |
props: { | |
user, | |
}, | |
}; | |
} | |
export default UserProfile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment