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

375
Vistas
How to properly destructure data from API call and directly use variables?

I get data from an API call (Headless CMS Strapi) and I'm using this data inside my Template (I'm using VueJS). The way I have to access this data is very painful. What would be a good way to use the data I receive from the API?

<template>
    <div>
        {{ audioPlayer.data.attributes.text }}
        <img :src="audioPlayer.data.attributes.image.data.attributes.url" alt="">
    </div>
</template>

<script setup>
    const config = useRuntimeConfig();
    console.log(config.public.strapi.url)
    const { data: audioPlayer } = await useFetch(`${config.public.strapi.url}/api/audio-player?populate=image`)
</script>

I would like to somehow use it like this

<template>
    <div>
        {{ text }} // or {{ audioPlayer.text }}
        <img :src="image.url" alt="">
    </div>
</template>

Of course I can reassign every bit of data in a new variable so I can access it directly. But is this really the best way to go?

about 4 years ago · Santiago Trujillo
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