Get Base URL from Javascript Helper function in a Laravel Project

I can Get base url of my laravel project from blade file in javascript section by using this

var APP_URL = {!! json_encode(url(‘/’)) !!}

But what should i do to get the base url when i am in a helpers.js like file

isValid(token){
        const payload = this.payload(token);
        if(payload) {
            return payload.iss == "http://127.0.0.1:8000/" || "http://127.0.0.1:8000/register" ? true : false
        }
        return false
    }

i want to get base url here rather asssigning the url separately.
Can anyone Help Me?

29 thoughts on “Get Base URL from Javascript Helper function in a Laravel Project”

Leave a Comment