A
A
alex4answ2020-05-25 20:20:08
API
alex4answ, 2020-05-25 20:20:08

How to get REST API page information?

Good afternoon, I studied open api , but did not find an answer to the question of how to get information for a page, for example:

There is a category page, for it you need to get:
1. Meta data (description title, h1, etc., etc.)
2. Product list

Worth whether to split it into 2 requests:
meta/:category
products/:category

or make a request like: /shop/:category
and get in response:

{
  name: 'My category',
  title: 'My category title',
  h1: 'H1 category',
  ...
  products: [
    ... // список продуктов { name: 'name', title: 'title', ... }
  ],
}


Please tell me, getting related data in the rest, I find only too primitive examples like "post-comments", but where are 3+ links, I can't find

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FinGanapre, 2020-05-26
@FinGanapre

In general, in the rest they try to make such endpoints that the application needs on the client side. But, in this case, I would pay attention to the fact that there can be a lot of products in a particular category and you will divide them by 10 / 20 / 50, etc. At the same time, it is more logical to get information about the category itself once. That is, I would divide it into two queries. And it will look much more logical when you need to get only a list of products of a certain category somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question