Reputation: 2835
Thinking is that any way to call the routes from route files with their names and get the url to axios in vuejs.
I don't know is it possible or not. If not please suggest me some other way to get the routes which i declared in laravel routes php files. Thanks
Upvotes: 0
Views: 1319
Reputation: 1840
<script>
window.routes = {
'users' : '{{ route('users') }}',
'contact' : '{{ route('contact') }}',
}
// You can access it like this
let route = window.routes.users
</script>
Upvotes: 0
Reputation: 74
One solution would be to do a Route::getRoutesByName
which will return all your routes keyed by the name you provided. You could create a route that returns that route collection.
See the API here: https://laravel.com/api/5.7/Illuminate/Routing/RouteCollection.html#method_getRoutesByName
Upvotes: 1