Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How would you structure these rest api endpoints

Let’s say you have 4 types of data that are displayed similarly across 4 pages of a website like videos, articles, posts, etc.

Would you have individual routes to get the most recent 10 for each like /type1/getall, /type2/getall, etc…,

Or would you have one route like getAllByType that takes the type as a param and returns the respective data.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks for your input

>Solution :

2nd method of defining a common route getAllByType with a param is the most used and recommended format because that way your routes structure is clean and it also avoids Redundant code. Hope it helps.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading