Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created February 22, 2023 09:26
Show Gist options
  • Save shameemreza/f7e78aa472f176f641779caba358d335 to your computer and use it in GitHub Desktop.
Save shameemreza/f7e78aa472f176f641779caba358d335 to your computer and use it in GitHub Desktop.
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