Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 400 code with 200 and empty array for response without comments #1265

Closed
akellbl4 opened this issue Feb 8, 2022 · 2 comments
Closed
Milestone

Comments

@akellbl4
Copy link
Collaborator

akellbl4 commented Feb 8, 2022

As I can see if a user doesn't have any comments then the server returns error 400 with data:

{
    "code": 1,
    "details": "can't get comment by user id",
    "error": "no comments for user twitter_500c776ee5c34f78a7e410277bf9f8f1ecd34145 in store"
}

Could we change this error to status 200 and empty array?

@umputun
Copy link
Owner

umputun commented Feb 8, 2022

i have changed the behavior to return 200 in this case. however, it also required to allow "empty" responses. Prior to the change the response was

	resp := struct {
		Comments []store.Comment `json:"comments,omitempty"`
		Count    int             `json:"count,omitempty"`
	}{}

in order to return {comments:[], count:0} I had to drop omitempty. Pls, check this pr branch as this is API change and the only thing we may affect here is UI

@akellbl4
Copy link
Collaborator Author

@umputun works fine!
CleanShot 2022-02-10 at 12 03 27@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants