M
M
Marat Linberg2018-08-04 22:03:21
PHP
Marat Linberg, 2018-08-04 22:03:21

How to make an API server?

I have an MVC project, well, a standard one made purely for tests and I'm just learning :))
So there are models in MVC, they have methods of working, with profiles ... something else ..
part of the page will be rendered using Ajax JS, for example, the number of some coins or a list of users, but I still use the current model in the Controller that pulls up the template, but in JS I can’t use the model.
After looking at how it pulls up the dynamic information of the trades, I found there...
https://api.trademc.org/shop.getOnline?shop=1&v=2
Question: How can I implement such a link in my MVC project, it seems like I don’t want to write a second time the same thing that is already written in the models, what to do in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-08-04
@Yan-s

Why do you need to write for the second time what is written in the models? A controller is written for the API method, and there is already an appeal to the existing logic. The model remains the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question