WordPress API Nav Menu
How to get nav menu items into Nuxt 3 through the WordPress REST API
Codingoblin
If you are encountering the error “Error: Ziggy error: route ‘your-route’ is not in the route list” the solutions is most likely very simple. This is an error I came across when using Laravel with Inertia.js and Vue.js. There are a couple of things you need to check to get this sorted.
If you are trying to resolve the Error: Ziggy error: route ‘your-route’ is not in the route list error, this is what you need to do:
I’m sure you have checked this already. But check that the route does actually exist. Make sure the name is EXACTLY the same. Check for a typo. I know it sounds obvious. But often it is something obvious!
The issue for me was that I had copied a route and pasted it. I had then changed the name of my copied route. However the original route and the newly created route both had the same url and request method. This meant that whilst it looked like the route did exist. It was getting overwritten by my newly created route. Simple solution is to change the url in the new route!
So you have a nice working route looking like this:
...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
->name('advert');
...
Then you copy the route and paste it to create a new similar route. You rename the route and your routes/web.php file looks like this:
...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
->name('adverts');
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
->name('adverts.my_adverts');
...
Everything seems fine. You have 2 routes with different names. But now you are encountering the Error: Ziggy error: route ‘your-route’ is not in the route list error.
The reason for this is that both routes are for GET requests, and they both have the same path! Simply changing the path of the second route will sort the problem out:
...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
->name('adverts');
Route::middleware(['auth:sanctum', 'verified'])->get('my-adverts', [AdvertController::class, 'index'])
->name('adverts.my_adverts');
...
I have videos too!
If you found this post helpful, please consider subscribing to the @codingoblin YouTube channel 😀
How to get nav menu items into Nuxt 3 through the WordPress REST API
Codingoblin
Here is my honest Tailwind UI review for 2023, updated for 2024. Is it worth using? Is it worth the money? Should you use an alternative?
Codingoblin
How to use roles and permissions in a Laravel Jetstream (Inertiajs) application using the Spatie Permission package.
Codingoblin
Sign up for my newsletter to stay up to date.