Friends, in the process of learning a new way for me to develop a kernel for a site, a number of questions arose. I would be grateful if you share your experience.

I read several articles on RESTful API, for example this one . Unfortunately, I didn’t see any special examples, the general concept is described everywhere. For example, the query

api / users /

gives (in the articles it is assumed that the answer comes in json format) a list of users, how to list this list on the page? It is logical that a structure (template) should be loaded earlier, in which there is a certain place under this list, then (omitting the question of loading a template) how to find out (i.e. get the ID of the element) is this place to insert the list there?

If we are talking about isolated cases, the question is not worth it, you can manually parse, invent something on the fly. But when the interface is complex, entities are dozens, then the question of automation inevitably arises.

Or, say, the current template is not designed for loadable data at all. That is, uploading a list of users, you also need to take a template for it somewhere. And somehow stuff the list by template ...

Tell me, brothers, how to solve such problems. Thank.

  • REST API is a concept of data retrieval. She is not very worried about who will use this data and how she is concerned about the availability of parameters and authorization. However, usually the REST API goes as a data source for the SPA, which is simply loaded from the root and loads templates, styles, etc. as usual statics (although templates can also be distributed by REST if desired). - etki
  • Getting acquainted with the materials, I found the point of view that the rest has exhausted the potential for today, precisely because it is precisely the concept of data release. That is, you can do anything, some will be scolded for a departure from the "party policy", and some say that the future is behind such an approach (as I understand, this is hypermedia habrahabr.ru/post/144259 , I have a poor understanding of this term) as an option - waiting for the message of those who do exactly that - hcuser

1 answer 1

@hcuser , you probably should get acquainted with the methods of implementing MVC ( Model-View-Controller ) on the client. A model is data obtained through a RESTful API, a view is a certain HTML template, a controller is javascript processing user actions. Fortunately, "everything is already stolen before us" and there are enough fashionable libraries / frameworks implementing this business. Some bright representatives:

They offer slightly different approaches, about all of them a lot of information on the same Habré.

To feel and compare the "taste" of these libraries - go to http://todomvvc.com/ and look at the sources of different implementations of a simple application - a to-do list.

  • Thank you very much. I have already looked into bekbon and angular, the meanings are roughly understandable, but in this case the goal is different - to understand and learn to do it myself. And therefore, maybe someone will share the experience of an independent path through the thorns to the stars. - hcuser
  • Himself is good, but not very practical. You can then take some template maker and drag the data with pens: - Nofate