Hi Contentful People :-),
I have a similar project to the above, but with multiple content types. Part of the JSON from Contentful looks like this:
{
sys: {
space: {
sys: {
type: "Link",
linkType: "Space",
id: "tlsglivqmxgd"
}
},
id: "5T9vhY0axU0sqim4Y68cca",
type: "Entry",
createdAt: "2018-11-08T21:05:52.814Z",
updatedAt: "2018-11-08T21:05:52.814Z",
environment: {
sys: {
id: "master",
type: "Link",
linkType: "Environment"
}
},
revision: 1,
contentType: {
sys: {
type: "Link",
linkType: "ContentType",
id: "boardOfDirectors"
}
},
locale: "en-US"
},
fields: {
one: "John Boyajy, 415-572-3303, johnboyajy@earthlink.net",
two: "Christina Bradley, 415-302-0396, cmtbradley@gmail.com",
three: "Judy Lichterman, 415-388-1022, menuet1022@aol.com",
four: "Karen Rogers, 415-892-9608, rogerskaren@comcast.net"
}
},
I have the script in a Nuxt file set up like this:
import {createClient} from '~/plugins/contentful.js'
const client = createClient()
export default {
// make use of your env variables
asyncData ({env}) {
return Promise.all([
client.getEntries({
content_type: env.boardOfDirectors_CT_ID
})
]).then(([entries]) => {
// return data that should be available
// in the template
return {
//access the items object of your JSON response
items: entries.items[0]
}
}).catch(console.error)
}
}
This is not working. I assume I’ve made a mistake in this section:
client.getEntries({
content_type: env.boardOfDirectors_CT_ID
})
Please advise