In this post I am going to explain how to get URL in js file in magento 2.
Use below code snippet to get URL in the js file.
define([
'jquery',
'mage/url'
], function($, url) {
// Login Page URL
var loginUrl = url.build('customer/account/login');
console.log(loginUrl);
// Customer Account URL
var accountUrl = url.build('customer/account');
console.log(accountUrl);
});Thats it. Enjoy Magento 2!!
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!


Leave a Reply