I have an API which returns a list of articles. An article can have three status: Approved, Pending and Rejected. Now the front-end needs to hit the API in following scenarios:
- Get all the articles irrespective of the status.
- Get all articles added by an user.
- Get all articles added by an user which are pending/rejected.
- Get all articles which are pending.
There are two buttons on the front-end: one for fetching all pending articles so that they can be approved(only available for admin users). Another for fetching all rejected and pending articles for the logged in user so that he can see his pending/rejected articles.
These two buttons are available on the list page of articles i.e. API has already been hit to fetch all articles and buttons are more like filters now.
Is it good to return following dict along with list of all articles on the first API call :
"self_view": ["Pending", "Rejected"]
So that front-end can know which all status need to be passed in the query params for filtering on subsequent button hits? Or should the logic which decides which filters to apply be hard-coded on front-end?
P.S Using Django for back-end and Angular for front-end.