开发者

If I want to get a list of all products that a certain customer has purchased, how would I express this relationship using RESTful conventions?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜