How to get apibaseUrl String in javascript in openmrs module.

Hello There, I have requirement to call an api in the module so I need the apibaseurl string to hit the api. Is there any way to get it. Mean while I am calling http://localhost:8080/openmrs/ws/rest/v1/location , instead of hardcoded url , Is there any way to make it dynamic. Thanks