0

Option 1:

Return as many links as there are resources.

{
        "teamName": "Steelers"
        "links": {
            "players": [
                { "href": "http://api.com/players/1" },
                { "href": "http://api.com/players/2" },
                { "href": "http://api.com/players/3" }
            ]
    }

It can see it being useful in the case we've already been caching some of the player resources on the client side.

Option 2:

Return a single link leading to the list of resources.

{
    "teamName": "Steelers"
    "links": {
        "players": [
            { "href": "http://api.com/teams/1/players" }
        ]
}

It looks a lot cleaner, and we can fetch the players in one request.

4

1 回答 1

1

我认为这个问题没有明确的答案,因为它取决于您的用例。在第一个选项中,我将为播放器的每个链接添加有关播放器的更多信息。

于 2016-01-28T10:23:51.387 回答