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

165
Vistas
How can I access to computed state from created

How can I access to my url state that I have in computed from created :

computed:{
    ...mapState({
        url: state => state.generics.myUrl,
    }),
},
created: function(){
        axios({
            method: 'GET',
            url: this.url
        }).then((response) => {

        });
    
},
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can create getter or try like following:

computed:{
...mapState({
    url: ({ generics: { myUrl} }) => myUrl,
  }),
},

const store = new Vuex.Store({
  state: {
    generics: {
        myUrl: 'https://reqres.in/api/products/1',
    }
  },
})

Vue.config.productionTip = false
Vue.config.devtools = false

new Vue({
    store,
    el: "#app",
    computed: {
    ...Vuex.mapState({
      url: ({ generics: { myUrl} }) => myUrl,
    }),
  },
  created() {
    axios({
        method: 'GET',
        url: this.url
      }).then((response) => {
        console.log(response.data)
      })
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/vuex "></script><script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.23.0/axios.min.js" integrity="sha512-Idr7xVNnMWCsgBQscTSCivBNWWH30oo/tzYORviOCrLKmBaRxRflm2miNhTFJNVmXvCtzgms5nlJF4az2hiGnA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="app">
  {{ url }}
</div>

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