I Have added a script ( JS File ) in Magento 2 admin side in my custom module. It added successfully but how to get Base URL in admin side js file.
I have tried this
Js file path ( app/code/Tym17/AdminSample/view/adminhtml/web/js/adminscript.js )
require([
'mage/url'
], function (urlBuilder) {
var customLink = urlBuilder.build('customer/account/login');
console.log(customLink);
});
But it gives me the current page full URL.
My layout file path ( app/code/Tym17/AdminSample/view/adminhtml/layout/adminsample_sampletwo_index.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<link src="Tym17_AdminSample::js/adminscript.js"/>
</head>
<body>
<referenceContainer name="content">
<block class="Tym17\AdminSample\Block\Adminhtml\Order" name="Overview" template="Tym17_AdminSample::sample/two.phtml" />
</referenceContainer>
</body>
How to get only base url like this http://127.0.0.1/magento/