Model Relationship: Lots of API calls in getting user information

Hello, I have been trying to explore the Auth0 implementation for SPAs just these past days so I am fairly new to it.

I’m getting confused with fetching user information. Just a background, I’ve done getting started for Django REST and React.

I understood how to make relationship by just referencing the Auth0 user_id to my backend server rather than the completely storing the user information. From what I understand this is the point of Auth0.

My confusion now is from doing api calls for get_users. An example would be listing blog posts with their authors.

A post has an author. Let’s say that I have displayed 20 posts in the frontend and I need to get the author information as well.

I can only reach to the conclusion that I should do a get_users call for each author of the post.

Would love to get some help with this. Thank you.

P.S.
I referred to these threads as well, but they are already closed which prompted to creating a new one related to the problem.

1 Like

Good morning @davemartinez and welcome to the Auth0 Community!

When it comes to getting users via the Management API we have the below documentation that has some excellent examples that should be able to shed some light on what you’re trying to do. Please give it a look and let me know if you have any further questions and we can work together on it.

1 Like

Hi James, thank you for the welcome.

By using get_users_by_id, I will be calling this endpoint 10 times when I have 10 posts right to get their authors?

My question right now is there a better way to do this because I think it’s too expensive to do this. I was hoping for some thing get_users_by_ids querying multiple user ids instead of one.

Or this case is essentially just how REST solves it?

Hey there @davemartinez, following up on this front.

If doing the bulk user search won’t serve then you will likely have to develop a script where you can pass each user_id of the array to generate the end result.

As always it’s important to be aware of the search best practices. Please let me know if you have any additional questions, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.