Skip to content

How to add a persitent query param #1999

Closed Answered by posva
evil-shrike asked this question in Help and Questions
Discussion options

You must be logged in to vote

The navigation guard you propose should work (I tested it):

router.beforeEach(to => {
  if (!('persistent' in to.query)) {
    return {
      ...to,
      query: {
        ...to.query,
        persistent: 'I am inevitable'
      }
    }
  }
})

Since the return is conditional, it won't face the infinite redirect issue you see with next()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants