My API call returns a picture
object that containts fields
and a url
value. When I try to query this in my code, however, it says undefined
though in Postman (or printing out as below) these elements CLEARLY exist.
I’m writing a Vue app so my code is as follows:
<template>
<div id="about">
<div v-for="(member, index) in team" :key="index" >
<ul v-for="(field, i) in member.fields.picture" :key="i">
<li>{{ i }}: {{ field }}</li>
</ul>
</div>
</template>
<script>
import {createClient} from '~/plugins/contentful.js'
const client = createClient()
export default {
// `env` is available in the context object
asyncData ({env}) {
return Promise.all([
// fetch all team members
client.getEntries({
'content_type': 'team',
order: '-fields.title',
})
]).then(([team]) => {
// return data that should be available
// in the template
return {
team: team.items
}
}).catch(console.error)
}
}
</script>