Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created February 22, 2023 09:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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