Proper REST response for empty table?

后端 未结 5 1001
遇见更好的自我
遇见更好的自我 2020-11-29 19:02

Let\'s say you want to get list of users by calling GET to api/users, but currently the table was truncated so there are no users. What is the prop

5条回答
  •  -上瘾入骨i
    2020-11-29 19:53

    If you are expecting list of user object, the best solution is returning an empty list ([]) with 200 OK than using a 404 or a 204 response.

提交回复
热议问题