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

341
Vistas
get updated query in nuxt plugin after page load

Well, I have a plugin with some functions in it, functions should update URL queries. The problem is, everytime I execute $global.changePage(2) or $global.changeLimit(2) the console.log(query) returns an empty object and didn't return updated queries in URL.

I know NuxtJS plugins execute once we load the page but is there any way to have updated query each time I use those functions?

export default (ctx: NuxtConfig, inject: Inject) => {
  const { app, query } = ctx;

  const global = {
    changePage (page: number) {
      console.log(query);
      
      app.router.push({
        query: { ...query, page }
      })
    },

    changeLimit(limit: number) {
      console.log(query);

      app.router.push({
        query: { ...query, limit }
      })
    },
  }

  inject('global', global)
  ctx.$global = global
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Simply remove ctx.$global = global from the last line of your plugin.

The inject method provided by Nuxt takes care of making your global object available where it's needed, so there's really no need for you to overwrite the ctx.$global property.

about 4 years ago · Juan Pablo Isaza Denunciar
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