Please use below code in your JS
file
definerequire([
"IOST",
"jquery",
"mage/url"
], function( iost, $, url ){
console.log(url) ;
});
function transfer(){
console.log(url.build) ;
}
OR you can use below code for your JS
definerequire(
['uiComponent', 'jquery', 'mage/url', 'Iostpay_Iostpaymagento::js/iost.min'],
function (uiComponent, $, url, iost) {
"use strict";
return uiComponent.extend({
initialize: function () {
this._super();
console.log(url);
},
transfer: function(){
console.log(url.build) ;
}
});
}
);
After changing this you need to run below commands
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
You can follow this JS
to understand how you can build URLs with the use of urlBuilder
and how to use mage/url
in your knockout JS.
vendor/magento/module-gift-message/view/frontend/web/js/action/gift-options.js
Hope this will work for you!