When I use the route helper function for example fetching the current page with route().current() I'm given the error Cannot convert undefined or null to object, this also occurs with getting a route with route('news.index').
In my app.js I'm defining the plugin and passing the exported config like so. However if I add globalThis.Ziggy = Ziggy; to the app.js the error goes away. Not sure if this is intended given I'm passing the config to the plugin.
Uncaught TypeError: Cannot convert undefined or null to object
at Function.entries (<anonymous>)
at n.u (ziggy-js.js?v=3272b7cd:743:29)
at n.current (ziggy-js.js?v=3272b7cd:751:65)
at NavBar.vue:21:28
at Proxy.findIndex (<anonymous>)
at NavBar.vue:16:49
at HTMLDocument.n (@inertiajs_vue3.js?v=3272b7cd:4157:16)
at f (@inertiajs_vue3.js?v=3272b7cd:3878:19)
at S (@inertiajs_vue3.js?v=3272b7cd:3885:16)
at @inertiajs_vue3.js?v=3272b7cd:3959:96
Ziggy version
2.1.0
Laravel version
11.1.1
Description
Hi,
When I use the
route
helper function for example fetching the current page withroute().current()
I'm given the errorCannot convert undefined or null to object
, this also occurs with getting a route withroute('news.index')
.In my
app.js
I'm defining the plugin and passing the exported config like so. However if I addglobalThis.Ziggy = Ziggy;
to theapp.js
the error goes away. Not sure if this is intended given I'm passing the config to the plugin.In my
NavBar.vue
script I have the followingonBeforeMount
to set the current active link for styling:Ziggy call and context
Ziggy configuration
Route definition