Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigateTo examples throw errors #15002

Closed
TheDutchCoder opened this issue Sep 21, 2022 · 1 comment · Fixed by nuxt/framework#7734
Closed

navigateTo examples throw errors #15002

TheDutchCoder opened this issue Sep 21, 2022 · 1 comment · Fixed by nuxt/framework#7734

Comments

@TheDutchCoder
Copy link
Contributor

Environment


  • Operating System: Darwin
  • Node Version: v16.15.1
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.12.1
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

N/A

Describe the bug

In the docs (https://v3.nuxtjs.org/api/utils/navigate-to/#navigating-within-a-vue-component) when using navigateTo in a component, it is said to use return in front of it, but this will throw a compiler error:

 ERROR  [@vue/compiler-sfc] 'return' outside of function. (2:0)                                 13:19:21

/Users/reinierkaper/projects/remx/apps/nuxt-app/pages/vision.vue
1  |  <script setup lang="ts">
   |                           ^
2  |  return navigateTo('/', { redirectCode: 301 })
   |  ^
3  |  </script>

Should it be awaited instead?

If so, I can PR a docs change if you like.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

Yes, we should definitely not return it in a <script setup> block. A PR would be gratefully accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants