Magento – How get admin url in js file

adminjavascriptmagento2

How get admin url in js file ?
Js file call AjaxController and this Js file are called to System -> Config from system.xml

Best Answer

You can try this this.values.baseUrl; in your js and you can also refer /var/www/html/magento2/vendor/magento/magento2-base/lib/web/mage/app/config.js

When you see admin page view source, enter image description here

you have admin base url, so you can get this base url using window.values.BASE_URL or may be window.BASE_URL.