Home > Mobile >  ASP.NET Core MVC consumes api javascript client-side with ajax
ASP.NET Core MVC consumes api javascript client-side with ajax

Time:11-30

I am currently working on an ASP.NET Core MVC project that consumes a Web API. I use javascript for client-side. The app lets you to leave a comment. When the button submit is pressed, I send a ajax request to post a comment but I send the request directly to api.

Is it a good practice, or should I make a request to my server (my project) and through the controller action call an API method?

Thank you!

CodePudding user response:

In my opinion, this is related with your requirement.

If your web api is public and it contains it own authentication requirement, I think you could directly connect to the web api, since this is public and open to every client.

If you have special requirement like log something and have some special logic at the backend, I suggest you could send the request to backend.

  • Related