Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:05:46+00:00 2026-06-10T14:05:46+00:00

I have a REST URL, say /users/<user_id>/entities which returns 2 objects within it: {

  • 0

I have a REST URL, say

/users/<user_id>/entities

which returns 2 objects within it:

{
    "players":
    {
       "test_player2":
       {
           "_id": "test_player2",
           "user": "f07590567f3d3570b4f35b4fd79f18b3"
       },
       "test_playerX":
       {
           "_id": "test_player2",
           "user": "f07590567f3d3570b4f35b4fd79f18b3"
       }
    },
    "games":
    {
      "game1" :{},
      "game2" :{},
    }
}

How do I design my Backbone Objects to use this data?

Requirement:
I want two different Backbone objects: Player, and Game, which should be populated via the same url (mentioned above).

PS: Is it even a correct practice to design this kind of REST URL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:05:47+00:00Added an answer on June 10, 2026 at 2:05 pm

    Is it even a correct practice to design this kind of REST URL?

    No, it’s not a correct practice. In REST, a single URL is supposed to represent a single resource. Therefore, your /users/<user_id>/entities URL should be /users/<user_id>/players and only return a list of players, and /users/<user_id>/games and only return a list of games.

    However, there may be a time when you have no control over what the API returns. Generally, this is the case for nested objects (you may be able to do it with what you have, but ideally, you’ll want to change your API):

    {
        "players":
        {
            "id": 1,
            "games":
            {
               "id": 1745,
               "title": "Team Fortress 2"
            }
        }
    }
    

    In which case, you would use the model’s parse function, with something like:

    parse: function(response)
    {
        // Make sure "games" actually exists and is an array to make a collection from
        if(_.isArray(response.games))
        {
            // Backbone will automatically make a collection of models from an array
            // Use {parse: true} if you want the receiving collection to parse as if a fetch had been done
            this.games = new GamesCollection(response.games,{parse: true});
        }
    }
    

    By overriding parse and using {parse:true}, you can build out your models pretty much indefinitely. It’s not necessarily ideal to do it that way (the idea is that each collection is responsible for its own models), but it works for those cases when you get compound objects and can’t change what the API returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a REST web service that currently exposes this URL: http://server/data/media where users
I have to map a REST Webservice URL like http://server:8080/application/service/customer/v1 to createCustomer method in
I have deployed a simple REST based application in RAD. A simple URL is
I have a scenario in which I have REST API which manages a Resource
I have a REST service that returns a JSON like this: [{@id:123,name:Name}] and I'm
I have a REST service for which I have a WADL file. I want
I have this script that displays all the users images which i will display
Let's say I have a url such as... http://www.example.com/ random-garbage-here-i-dont-want-12392 /video 2983439 Is there
I have a project (say myproject) in which I have hosted a CXF RESTful
I have a rest web service whose url is /services/fetchData?id=value&name=value&date=...... In the above if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.