Create/Update Commerce API documentation with Axios examples #307
-
What are you trying to do? What's your proposed solution? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hey @Stalex89, we’ve got a Controller Actions page for the Commerce documentation that’ll be launching alongside Commerce 3.3. It’s modeled after Craft’s own Controller Actions page and it should help in this case. Take a peek here if you’d like: https://github.com/craftcms/docs/blob/next/commerce/docs/commerce/3.x/dev/controller-actions.md There aren’t Axios-specific examples, but that would look similar to the jQuery example here: https://craftcms.com/docs/commerce/3.x/orders-carts.html#fetching-a-cart |
Beta Was this translation helpful? Give feedback.
-
Hi @mattstein, thank you very much for the information, I will check it 😃 |
Beta Was this translation helpful? Give feedback.
-
Also snuck in an Axios example here just for good measure: https://craftcms.com/docs/commerce/3.x/orders-carts.html#fetching-a-cart 🤫 |
Beta Was this translation helpful? Give feedback.
-
For anyone joining late—we've overhauled the Controller Actions page. In the process, we opted to purge library-specific examples from Craft and Commerce documentation, preferring to teach only concepts that apply to all requests (like how to work with CSRF, headers, etc.) in the context of the widely-supported Cart management follows the same patterns, so any params sent via Twig examples can also be sent via Ajax as I encourage everyone to review the new pages and let us know how you do with your headless applications! 💞 |
Beta Was this translation helpful? Give feedback.
For anyone joining late—we've overhauled the Controller Actions page. In the process, we opted to purge library-specific examples from Craft and Commerce documentation, preferring to teach only concepts that apply to all requests (like how to work with CSRF, headers, etc.) in the context of the widely-supported
fetch()
API.Cart management follows the same patterns, so any params sent via Twig examples can also be sent via Ajax as
FormData
or a JSON payload! The core principles (covered in the Ajax section) all apply to Craft 3.x and Commerce 3.x, as well.I encourage everyone to review the new pages and let us know how you do with your headless applications! 💞