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

How to access query parameters #135

Closed
dan-gamble opened this Issue Jan 15, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@dan-gamble
Copy link

dan-gamble commented Jan 15, 2017

Things like /objects?page=2.

When doing:

    async data ({ params }) {
      try {
        let BASE_URL = `http://localhost:8080/api/v1/nations`

        const { data } = await axios.get(BASE_URL)

        return {
          currentPage: data.currentPage,
          nations: data.data
        }
      } catch (e) {
        console.error(e)
      }
    }

I'm not sure how to access the this.$route.query.page.

this is undefined and params doesn't hold any query data, just the id i believe.

This question is available on Nuxt.js community (#c113)
@alexchopin

This comment has been minimized.

Copy link
Member

alexchopin commented Jan 15, 2017

You can access with the key query which is an alias of this.$route.query (like params in your example).
The documentation is not very complete but you can see the key here: https://nuxtjs.org/api/pages-context

@dan-gamble

This comment has been minimized.

Copy link

dan-gamble commented Jan 15, 2017

Thanks, i should've checked the API part instead of just the guide :)

@alexchopin

This comment has been minimized.

Copy link
Member

alexchopin commented Jan 15, 2017

No worries, the documentation is still messy now. :)

@lock

This comment has been minimized.

Copy link

lock bot commented Nov 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.