I am creating a simple blog front end to consume a django backend api. The way it is setup so I can access user data for each post is like this:
post serializer:
class PostSerializer(serializers.ModelSerializer):
class Meta:
model = Post
fields = ['id', 'title', 'body', 'user']
depth = 1
react, where i display the data
<Container variant='lg' maxWidth='lg'>
<div className='posts'>
<Typography key={post.id} variant='h3'>
{post.title}
</Typography>
<Typography paragraph>
{post.body}
</Typography>
<Typography paragraph>
{post.user.user_name}
</Typography>
</div>
</Container>
Now, this does fit as a solution to my problem, in order to have the users username be displayed in post, but it exposes all user data, including email, password hash, last logged in, etc.
What is better way to get user related data when using react?