I want to retrieve a base URL and append it with my module controller link from a JS file, so it's impossible to use a block to get the base URL. So far I've done this:
define([
'jquery',
'mage/url'
], function ($,url) {
var linkUrl = url.build('namespace_module/regions/index');
console.log(linkUrl);
});
But I only got this result:
namespace_module/regions/index
BASE_URL
to get the base URL in js. Check the below answer to check how it works: magento.stackexchange.com/a/336194/35758