Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created February 22, 2023 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shameemreza/675165cb6c0f718ba39d4a50f738f5a0 to your computer and use it in GitHub Desktop.
Save shameemreza/675165cb6c0f718ba39d4a50f738f5a0 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 { id } = context.query;
// Fetch data for user with id
const res = await fetch(`https://api.example.com/users/${id}`);
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