I am trying to adapt the Contentful with Nuxt tutorial to use the Nuxt Composition API which hopefully soon will be part of Nuxt 3 and also using nuxt-vite. The script part of my index.vue looks like this:
<script lang="ts">
import { defineComponent, useAsync, useContext } from '@nuxtjs/composition-api';
import useContentful from '~/plugins/contentful';
import { IBlogPost, IPerson } from '~/types/generated/contentful';
const CTF_PERSON_ID = '15jwOBqpxqSAOy2eOO4S0m';
const CTF_BLOG_POST_TYPE_ID = 'blogPost';
export default defineComponent({
setup() {
const { env } = useContext();
const { client } = useContentful(env);
const person = useAsync(() => client.getEntry<IPerson>(CTF_PERSON_ID));
const posts = useAsync(() => {
return client.getEntries<IBlogPost>({
content_type: CTF_BLOG_POST_TYPE_ID,
order: '-sys.createdAt',
});
});
return {
person,
posts,
};
},
});
</script>
I rewrote the example code of the createClient code to also follow the composition API standard and it seems to work as I can see the request and response in the debugger. The problem comes when the response is processed by contentful:
Uncaught (in promise) TypeError: (0 , _fastCopy.default) is not a function
at wrapEntryCollection (entry.js:118)
at Object.getEntries (create-contentful-api.js:243)
at async Object.getEntry (create-contentful-api.js:200)
I am aware that I use some experimental features, but as the error happens within the contentful code, maybe something else causes the problem.