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!!