Let's say you have your global scripts file and you don't want to define that URL repeatedly in other files. That's the point where BASE_URL kicks in.
In your global_script.js file, do this
<script>
var BASE_URL = "http://localhost:8000";
</script>
Then you can use that variable anywhere else to call your URL. For example...
<script>
fetch(`{{BASE_URL}}/task-create/`,{
..............
}).then((response) => {
.............
})
</script>