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.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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