0

i am doing several custom modules in Magento 2.

It is a good practice do all the thing orientated to API (thinking in be consume for an mobile app for example ) and also use those api internally in the view model?

Or should i create a controller for return json to the view model and API just for external calls?

For example, i want to show a popup with a list of products using KOjs.

should i use a controller to return the products of that AJAX call o can i use the magento 2 API "rest/V1/products"

1 Answer 1

1

Better to go with webapi.xml and create REST end point approach.

Because you can easily adapt the Magento customer/admin inbuilt token-based restrictions against the APIs.

1
  • webapi.xml and REST are the correct way to go. When in doubt, take a look at the Magento native checkout, they do exactly that Jan 25, 2021 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.