Tuesday 23 May 2017

Select specific data in REST

I am currently building an nodeJS api using express and mongodb and i am trying to follow as much as possible the REST approach and i don't know what is the best way to select the specific data of a resource

For example, If I have the model user with first name, last name, email and password i would have to use:

GET -> http://localhost/users -> To get all users
GET -> http://localhost/users/12 -> To get the user with ID 12

If I wanted to select only the first name and last name, what would be the correct url structure?

This way would be correct ?

http://localhost/users?select=firstName,LastName
http://localhost/users/12?select=firstName,LastName

Sorry for my poor english!



via user2888716

No comments:

Post a Comment