TypeError: app.get is not a function
zacklerner opened this issue · 3 comments
First off, thanks for the plugin! I'm in the process of implementing search for a site that uses Sanity as a headless CMS and Gridsome for SSG.
I'm getting the following error when running gridsome develop
:
Serving search index
TypeError: app.get is not a function
at CreateSearchIndex.api.configureServer.app (/Users/zack/Sites/sanity/sanity-gridsome-blog/web/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:39:9)
Here are the contents of package.json with the versions of Gridsome and the Flexsearch plugin:
{
"name": "sanity-gridsome-web",
"private": true,
"scripts": {
"build": "gridsome build",
"dev": "gridsome develop",
"explore": "gridsome explore"
},
"dependencies": {
"@gridsome/plugin-google-analytics": "^0.1.0",
"@sanity/image-url": "^0.140.15",
"dotenv": "^8.1.0",
"gridsome": "^0.7.1",
"gridsome-plugin-flexsearch": "^0.1.9",
"gridsome-source-sanity": "^1.0.1",
"sanity-blocks-vue-component": "^0.1.0"
},
"devDependencies": {
"node-sass": "^4.12.0",
"sass-loader": "^8.0.0"
}
}
And finally, here's the config of my collection as well as the Flexsearch plugin in gridsome.config.js:
module.exports = {
...
plugins: [
// Sanity source plugin config
{
use: 'gridsome-source-sanity',
options: {
...clientConfig.sanity,
typeName: 'Sanity',
token: process.env.SANITY_TOKEN,
overlayDrafts: !isProd,
watchMode: !isProd
}
},
// Flexsearch plugin config
{
use: 'gridsome-plugin-flexsearch',
options: {
collections: [
{
typeName: 'Sanity',
indexName: 'Sanity',
fields: ['title']
}
],
searchFields: ['title']
}
}
...
]
}
Any info on what may be causing this would be greatly appreciated. Thanks again!
Hey @zacklerner!
I believe that the api.configureServer
hook was added in gridsome v0.7.3
. So I am afraid that to use this plugin, you will need to update to at least that version...
Let me know if that doesn't fix the issue...
@thetre97 That resolved the error! Thanks so much for the quick response.
No problem, thanks for raising it - I have added a note about that on the readme...