I'm creating a blog in my nuxt-app that pulls data from contentful ive been following this tutorial, now I can get that all right, but I cant seem to get both context and the environment variables I set up to return from the asyncData argument
I have created a json file like so..
.contentful.json
{
"CTF_BLOG_POST_ITEM": "...",
"CTF_BLOG_POST": "...",
"CTF_SPACE_ID": "...",
"CTF_CDA_ACCESS_TOKEN":"..."
}
and then in my nuxt.config.js
env: {
CTF_SPACE_ID: config.CTF_SPACE_ID,
CTF_CDA_ACCESS_TOKEN: config.CTF_CDA_ACCESS_TOKEN,
CTF_BLOG_POST_ITEM: config.CTF_BLOG_POST_ITEM,
CTF_BLOG_POST: config.CTF_BLOG_POST
}
now basically in my component I've been trying to do this
asyncData(context, {env}) {
return Promise.all([
client.getEntries({
'content_type': env.CTF_BLOG_POST_ITEM,
order: '-sys.createdAt'
})
]).then(([posts]) => {
console.log(context);
return {
posts: posts.items
}
})
},
but when I run this I get cannot read property CTF_BLOG_POST_ITEM of undefined, if I take context out of the arguments this works, and vice versa if I take the {env} I get the context.
How can I get both??
Thanks