I need to achieve this via an AJAX call, where a handy helper function (on the server) would do the trick, yet what is the REST way of doing it?
I have a list of items(cats) at the browser side, And I need to populate another detail for all those items.
input = [list of cat ids]
output = [list of {}s which has cat ids & age]
If I need not to care about proper REST API, I would just declare a method populate_cat_details() and would invoke it via GET http://example.com?method=populate_cat_details&cat_ids=1,2,3,4 that returns a JSON
GET http://www.example.com/cats -> return all cats
GET http://www.example.com/cats/:id -> return 1 cat by id
GET http://www.example.com/cats?id=x&id=y&id=z -> return n cats matching ids
GET http://www.example.com/cats?age=2&age=3&age=4 -> return n cats matching ages
GET http://www.example.com/cats?id=x&id=y&id=z&age=2&age=3&age=4 -> return n cats matching ids and ages
You have other ways if passing parameters like coma-separated values ex: ids=1,2,3
take a look here: http://www.restapitutorial.com/lessons/restfulresourcenaming.html