Skip to content

What to return if a collection is empty? #101

@gabrielgrant

Description

@gabrielgrant

What should be returned when an empty collection is queried?

a hash with an empty array?

example 1

GET /photos

HTTP/1.1 200 OK
Content-Type: application/json

{
  "photos": []
}

example 2

GET /photos

HTTP/1.1 200 OK
Content-Type: application/json

{
  "photos": [],
  "meta": {
    "client-ids": true
  }
}

or an empty hash?

example 3:

HTTP/1.1 200 OK
Content-Type: application/json

{}

example 4:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "meta": {
    "client-ids": true
  }
}

I think a hash with an empty array is probably less likely to cause surprises and would be happy to provide a patch if you agree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy