Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda