S
S
semolex2015-11-02 23:02:41
Angular
semolex, 2015-11-02 23:02:41

How to combine objects with RESTful API using Angular?

Hello!
Now I will try to explain the situation:
There is a REST Api that returns all objects (Python Flask) in this form:
"/catalogues/<_id>" - returns objects from the catalog by id
"/catalogues/" - returns all objects from the catalog by id
" /items/<_id>" - returns all objects that are in the directory
"/items/" - returns objects that are in the directory by id

So here is an example of a response from /catalogues/<_id>:

{catalog_image: 4, catalog_name: 1, id: 1, items: 1, object_name: "M31"} ,
{catalog_image: 3, catalog_name: 1, id: 2, items: 2, object_name: "M45"}

where, for example, items contains the id of the item object.
example item:
{name: "My Item", id: 1"}
So, how can I make it so that I can combine these requests, that is, I get an object of the form
{catalog_image: 3, catalog_name: 1, id: 2, items: My Item, object_name: "M45"}
??
Or the simplest option is to combine everything on the backend, with a selection from the database (JOINom) ... but then the REST idea is lost ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-11-02
@semolex

angular has nothing to do with it. You have to sort this out yourself. You can also look at libraries for working with the rest api (restangular, ngResource, js-data or any other popular one).
Well it is more like Yes. Resources are resources. They have nothing to do with the base. But if for some reason you need to link resources together, then this is not a problem. Your apish, if you have control over it, should be easy to use in the first place, restfull pens can be left if it is not of practical use.
ps if you don't understand - I suggest you read the examples from jsonapi.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question