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.

Thats it. Enjoy Magento 2!!