REST API endpoint standard

Asked

Viewed 333 times

-2

I’m creating an application similar to Twitter using Laravel and React, where the database has tables: Post, User, Relation, Mention and Repost. On the 'Timeline' screen of the application will be displayed information of all tables of my database.

My question is, I build an endpoint /Timeline for React to get all the information from an endpoint, or on the Timeline screen it must have an endpoint for each one (/post, /user, etc...)?

1 answer

0


In the frontend, you will make HTTP requests to get the necessary information for the user interface. It does not matter how the method of obtaining the information is implemented in the backend. What is required should be required through an HTTP request.

It can be a single request, it can be many. It depends on how the backend is built. It’s up to you to create a unique route to your React app. If your vision is an API that becomes public, it might not be a good idea. I think your question fits the theme of good practice to build an API. If it were me, I would leave the modularized backend API for each resource, regardless of which frontend is using it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.