I designed a RESTful web API that has an endpoint that outputs objects in this structure:
{
"id": 2,
"name": "Test Object",
"owner": 3,
}
The "owner" is also represented by a separate API endpoint which gives more data about the particular user who owns the object. Neat.
What I'm trying to do is, upon retrieving the objects (either via query or get), to also look up each user by ID and replace the "owner" attribute of the objects with an object containing user data like a username and email address. For reference, I'm trying to use this in a template using ngRepeat.
Is there any practical way to do this? Or should I simply redesign the API to output the related data automatically? I haven't found any resources on RESTful APIs that point me in one direction or the other.
Thanks!