Using @routes results in: Uncaught ReferenceError: Ziggy is not defined
See original GitHub issueCurrently installed Laravel version:
5.6.39
Currently installed Ziggy version
0.6.9
I’ve included the @routes directive in the header of my template.
Here is the output in the header.
<script type="text/javascript">
(function() {
var routes = {"api.mailgun.cases.test":{"uri":"api\/mailgun\/cases\/test","methods":["GET","HEAD"],"domain":null}};
for (var name in routes) {
Ziggy.namedRoutes[name] = routes[name];
}
})();
</script>
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
ReferenceError: route is not defined · Issue #265 · tighten/ziggy
I have an issue with Ziggy, I was using it first with the directive @routes but after switching to the artisan method the...
Read more >Laravel - Ziggy Err: $route is not a function - Stack Overflow
I would like to use the ziggy library to build routes. And my error in browser console: Uncaught (in promise) TypeError: _ctx.$route is...
Read more >Ziggy, InertiaJS & Vite : route is not defined - Laracasts
Everything works fine on my Vue templates, but I got this js error (Uncaught ReferenceError: route is not defined) when I use the...
Read more >Asset Bundling (Vite) - The PHP Framework For Web Artisans
Watching the routes/** directory is useful if you are utilizing Ziggy to generate route links within your application's frontend. If these default paths...
Read more >a package providing Laravel Named Routes in JavaScript
One thing we've come back to a few times is the desire to use the Laravel route() helper with named routes in JavaScript....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
import route from 'ziggy'
only imports the helper function.If you’ve generated the routes file with the artisan command, e.g.
php artisan ziggy:generate "resources/js/ziggy"
, you’ll need to import that file as well.To use the route helper function, you need to make the generated routes accessible. I’ve just bound to the window object below, but you can import it into your Vue components as described in the docs if you prefer.
Hopefully that clears things up for you!
Perfect! That solves it for me, thank you!