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

208
Vistas
Nuxt SSR app does not share date from store between two windows

I have a Nuxt SSR app which need to open new window on link click, but new window does not have actual data in the store. There are only default values. How can I share actual values in the store between this two pagaes?

This is the code of new page which ask for currency value:

<template>
  <DeviceDetail :pdevice="device" :location="location" />
</template>

<script>
import { defineComponent } from '@nuxtjs/composition-api'

export default defineComponent({
  async asyncData(context) {
    try {
      const deviceId = context.params.device_id.split('-').pop() // url == device-name-id
      const currency = context.store.state.i18.currency // This is a problem
      const route = context.route

      const { data: device } = await context.$api.devices.getDeviceDetail(
        deviceId,
        currency
      )

      const locationId = device.data.location_id

      const { data: location } = await context.$api.locations.getLocation(
        locationId
      )

      return {
        device: device.data,
        location: location.data,
      }
    } catch (error) {
      console.error(error)
    }
  },
  data() {
    return {
      device: null,
      location: null,
    }
  },
})
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Yes, if you open a new tab, Vue will need to re-hydrate from the start, you cannot transfer the state from one page to the other with just Vue.

You'll need to use something to persist the data. A quick search brings up this exact answer with quite more details: https://stackoverflow.com/a/66872372/8816585

So, using localStorage could be a simple and quick way of getting things done

localStorage.setItem('persistThisData', JSON.stringify(coolData))

Then, on the other side

const coolData = JSON.parse(localStorage.getItem('persistThisData'))

Query params could also be a solution with

this.$router.push({ path: '/nice-page', query: { type: 'beautiful' } })

And getting it on the other side with

this.$route.query.type

A conditional checking if coolData is populated in the other page (yet, same file) and everything should be working fine.

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