Get a list of countries available for shipping with Ajax in Craft Commerce I need to fetch a list countries available for shipping in Craft Commerce.
The problem is that I use decoupled frontend on Nuxt.js and I need fetch it with Ajax call and not with the twig code.
I tried to call it in a Postman but it returns me a 403 - Forbidden error with message &quot;User is not permitted to perform this action&quot;.
I couldn't find something about the way of making request through Ajax in Commerce documentation, can you please tell me what I'm doing wrong here?
You need to provide a CSRF token, alternatively turn it off in your config/general.php file.
Set a token in your twig template:
{% set csrfToken = {
    csrfTokenName: craft.app.config.general.csrfTokenName,
    csrfTokenValue: craft.app.request.csrfToken,
} %}

&lt;script type=&quot;text/javascript&quot;&gt;
    window.Craft = {{ csrfToken|json_encode|raw }};
&lt;/script&gt;

Then include the CSRF token name and value in your post array (data):
data[window.Craft.csrfTokenName] = window.Craft.csrfTokenValue;

Alternatively you can set enableCsrfProtection to false in your general config file.