So if I wanted to get a list of all products, I'd use an HTTP GET request on /products, and if I wanted to get a specific product, I'd us开发者_高级运维e an HTTP GET request on /products/:id, but what is the convention if I want to get a list of all of the products that a certain customer has purchased? Using a nested resource in this case wouldn't make sense.
You can go a couple of ways here, but the noun here is really a "purchase"
So /purchases
could be your list of purchases.
/purchases/1
and /purchases/2
are the first and second purchases you created.
"transactions" would work just as well here.
精彩评论