I'm new to express and apis, and I'm currently building a RESTful API with Express. For example let's say this is my model.
Sheep = {
name: String,
age: Number,
color: String
}
Aside from basic CRUD operations I saw from this tutorial, like create a Sheep, read a Sheep by id, update a Sheep by id, and remove a Sheep by id are there other operations I should include in my api?
In particular I'm wondering if I should make routes for find a sheep by name/age/color for example and how in best practice I would handle the routes for that.
I'm probably lacking information, but by the tutorial above, the route to find a sheep by id is "/sheeps/:sheepId"
. How would I make a route to find by name? If I do "/sheeps/:sheepName"
would that not be identical to find sheep by id because if I go to my browser and go for example: "localhost:8080/sheeps/someNameOrId"
how would the browser or in particular the client side recognize if it is a name or an id?
I'm working with AngularJS as my client if that could help build a more helpful answer.
via S. Jung
No comments:
Post a Comment