Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Can't fetch route params or query in asyncdata on production with nuxtjs

I've built a search page which sends a request to the wordpress json api. The asyncData method gets it params by submitting a form in a header component. On submit I call the this.$router.push({ name: 'suche', params: {search: this.searchInput}}). On localhost with npm run dev everything works like it should. But when I deploy the route.params.search is undefined in asyncData. I tested to display $route.params.search and it works on both local and production mode (target: static).

asyncData in suche.vue:

async asyncData({route, $axios }) {
            try {
                // console.log(params.search);
                // const anfrage = params.search;
                const query = route.params.search
                const search = await $axios.$get(`https://wp-api.com/wp-json/wp/v2/multiple-post-type?search=${query}&type[]=post&type[]=project&per_page=20&_embed`)
                return { search }
            } catch (error) {
                if (error.response) {
                    // Request made and server responded
                    console.log(error.response.data)
                    console.log(error.response.status)
                    console.log(error.response.headers)
                } else if (error.request) {
                    // The request was made but no response was received
                    console.log(error.request)
                } else {
                    // Something happened in setting up the request that triggered an Error
                    console.log('Error', error.message)
                }
            }
    }  

I also tested the router push with path and query.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!