I am trying to use Nuxt.js Content in my project.
The problem is that when I try to use $content method in my project the TypeError: _this.$content is not a function
occurs:
JavaScript
x
4
1
async fetch() {
2
this.content = await this.$content('data').fetch()
3
},
4
I imported the @nuxt/content
in Nuxt config and in typescript config.
nuxt.config.js
JavaScript
1
4
1
export default {
2
modules: ['@nuxt/content']
3
}
4
tsconfig.json
JavaScript
1
6
1
{
2
"compilerOptions": {
3
"types": ["@nuxt/types", "@types/node", "@nuxt/content"]
4
}
5
}
6
Advertisement
Answer
Nuxt content v2 needs Nuxt3. If you’re using Nuxt2, you should use the v1.
As stated at the end of this page: https://content.nuxtjs.org/get-started#render-pages