TRU API - abukhalil-LTUC-ASAC/amman-401d4 GitHub Wiki

A proper data endpoint!

Is a bunch of practices that would make API calls predictable and as easy as slicing butter. Calling the specific url route to get what you need to move on.

URL routing and Data

What could be offered in a route, is your custom route that is prefixed before the actual route. Mostly for clarification purposes such as with /api/v1/ which shows that everything in the URL is about the API, if your website includes other pages and routes for anything other than the API.

Some problematic routes could happen when you'd specify params within a route /:id, then want to extend that same route /new for other purposes, the catch is to require a middleware with express.Route() and then call /new before /:id as shown in this question.

URL path using /:id or any other name /:name has no effect on the value expected but rather the variable needs to match data.params.[insertVar]. A more descriptive methods for express using route params is found in this.link.

Forms of data sent by the browser could take many forms, some you might have seen such as form data with POST, GET and params. More details.

Vocabs

  • Routing is the process of moving in a certain path in a network, in a selected pattern. Routes can also be defined in a useful manner such as the above for the API.
  • Route Prefixing is the predefined route for the URL path to reach a certain point, usually done to define API's or subdomains.
  • Request “Body” is your data.
  • Request “Query” is what is intended for data manipulations
  • Request “Params” makes use of different functions for the same route per param.