I'm trying out Gridsome and Vue.js for a fairly large website conversion. The website needs to be able to load data from an API. I've been trying to follow the instructions on https://gridsome.org/docs/fetching-data/#import-from-apis - I pasted in the example code.
However, I'm getting this error when I try to run gridsome develop
C:\projects\folder\project>gridsome develop Gridsome v0.6.9
Initializing plugins... Initialize - 0.97s TypeError: actions.addCollection is not a function at api.loadSource (C:\projects\VueJS-Research\my-gridsome-test-VS\gridsome.server.js:17:36) at process._tickCallback (internal/process/next_tick.js:68:7)
being new to Vue.js, I'm not sure what's going on here. is there a package I'm missing?
I have to say, if following the documentation causes these kinds of issues, I might have to conclude that Gridsome is not mature enough to use in a commercial setting and we might have to look somewhere else.
Any help would be appreciated, Thanks.
code in the gridsome.server.js file:
const axios = require('axios')
module.exports = function (api) {
api.loadSource(async actions => {
const { data } = await axios.get('http://dev.client.local/api/items/suggestitems?family=someCategory')
const collection = actions.addCollection({ typeName: 'clientItems' })
for (const item of data) {
collection.addNode({
label: item.label,
labelNoFamily: item.labelNoFamily,
path: item.path
})
}
})
//api.loadSource(({ addContentType }) => {
// // Use the Data Store API here: https://gridsome.org/docs/data-store-api
//})
api.createPages(({ createPage }) => {
// Use the Pages API here: https://gridsome.org/docs/pages-api
})
}