Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

365
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!