question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing param for named route "notfound": Expected "0" to be defined

See original GitHub issue

I got this quite cryptic error message and I’m not sure what to make of it.

Relevant trace

assert          @ vue-router.js?e71f:140
fillParams      @ vue-router.js?e71f:1158
match           @ vue-router.js?e71f:1007
transitionTo    @ vue-router.js?e71f:1223
replace         @ vue-router.js?e71f:1628
replace         @ vue-router.js?e71f:1801
created         @ edit.vue?dc4c:116

Offending code in edit.vue

this.$router.replace({
    name: 'notfound',
})

Relevant routes

{
    path: '*',
    name: 'notfound',
    component: require('./views/NotFound.vue'),
},

NotFound.vue

<script>
export default {
    data() {
        return {
        }
    },
}
</script>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

32reactions
polunzhcommented, Dec 19, 2016

Same error, I don’t know why; but I fixed it with the following code:

routes: [{
        name: '404',
        path: '/404',
        component: NotFound
    }, {
        path: '*',
        redirect: '404'
    }
]
29reactions
zaninycommented, Dec 7, 2017

The fact is that when you do redirect to an asterisk, the router does not know which path should be in the location. You must pass this path yourself, eg:

push({ name: '404', params: { '0': 'somePath'} })

Here is a piece of my code from route guard for subdomains support, maybe useful

/**
 * Check hostname.
 *  
 * @param  {string} hostname 
 * @param  {Array} routes
 * @return {Array}
 */
function hostGuard(hostname, routes) {
    return beforeEnter(routes, (to, from, next) => {
        if(location.hostname.split('.').shift() === hostname) {
            next()
        }
        else {
            next({ name: '404', params: { '0': to.path } })
        }
    })
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue router - missing param for named route - Stack Overflow
This is a common mistake when you try to render 'detail.id' for the first time. Probably property 'id' is undefined. So you can...
Read more >
[Solved]-Vue router - missing param for named route-Vue.js
This is a common mistake when you try to render 'detail.id' for the first time. Probably property 'id' is undefined. So you can...
Read more >
Handling 404 errors with Vue Router - A. Muponda
Using the asterisk ( * ) in the Vue Router object definitions ... missing param for named route "notFound": Expected "0" to be...
Read more >
Missing param for named route "X": Expected "Y" to be defined
The route that I'm trying to create is the /:name that will happen when I click on a name at a table inside...
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found