Answer the question
In order to leave comments, you need to log in
How to correctly use the API?
I have a list of partners that I use via the REST API.
There is an order page in which I have to use contractors.
How to use it correctly to do it?
1) Request in the browser via JavaScript
2) Make a request to the database (or access its own API via HttpClient) in the View (View)
3) Access the database in the Controller (duplicate the code that is in the API) and pass it to the View (View)
4 ) Maybe there is a "simple" mechanism for accessing the API from the Controller / View
Answer the question
In order to leave comments, you need to log in
Make a separate service in which you will receive a list of counterparties through the api.
Inject this service into the controller.
In the controller method, through this service, get counterparties and this data, together in the viewModel, give it to the view.
4) A simple mechanism, this is HttpClient, there is nowhere easier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question