NuxtJS plugin that creates a clean and elegant way to fetch data from DatoCMS.
- Add
nuxt-datocmsmodule to your project
# Navigate to modules directory of Nuxt project
cd modules
# If modules doesn't exist, create it
mkdir modules && cd modules
# Clone this repo to modules directory
git clone https://github.com/StudioRotate/nuxt-datocms.git- Add required module dependecies
yarn add datocms-listen graphql graphql-requeset- Add
nuxt-datocmsto themodulessection ofnuxt.config.js
/// nuxt.config.js
{
modules: [
// Simple usage
['nuxt-datocms', {
options: {
datoToken: <DATO-API-TOKEN> // Add Dato API token
}
}]
]
}Or a separate section nuxt-datocms for module options:
// nuxt.config.js
{
modules: [
// Simple usage
'nuxt-datocms',
],
'nuxt-datocms': {
options: {
datoToken: <DATO-API-TOKEN> // Add Dato API token
}
}
}- Test fetching data from DatoCMS within a page's
asyncDatalifecycle method.
async asyncData({ $cms }) {
const data = await $cms.records.fetchRaw(`query {
_site {
locales
}
}`)
console.log(data)
}For all configuration, further setup and usage information, please read the parent Plugin Docs.
This module is currently a forked and modified version of @ajshortt/nuxt-datocms. It is recommended that changes be made on an instance-by-instance manner. However, if the changes are very useful to other instances, please submit a PR within the module repo
