gatsby-source-apiserver
是一个gatsby源插件,用于提取第三方api数据。
当我使用两个gatsby-source-apiserver
插件从不同的URL获取数据时,它可以工作。
但是当我添加第三个时,它不起作用
我尝试了第三种方法,但是使用gatsby build
在构建时间上却出错。
错误:
gatsby build
success open and validate gatsby-configs - 0.225 s
success load plugins - 35.556 s
success onPreInit - 0.005 s
success delete html and css files from previous builds - 0.142 s
success initialize cache - 0.309 s
success copy gatsby files - 2.744 s
success onPreBootstrap - 0.058 s
ERROR #11321 PLUGIN
"gatsby-source-apiserver" threw an error while running the sourceNodes lifecycle:
Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
- normalize.js:138 standardizeKeys
[xxx-xxx]/[gatsby-source-apiserver]/normalize.js:138:46
- normalize.js:29 Object.exports.createNodesFromEntities
[xxx-xxx]/[gatsby-source-apiserver]/normalize.js:29:14
- gatsby-node.js:115
[xxx-xxx]/[gatsby-source-apiserver]/gatsby-node.js:115:19
- Generator.next
- gatsby-node.js:1 step
[xxx-xxx]/[gatsby-source-apiserver]/gatsby-node.js:1:253
- gatsby-node.js:1
[xxx-xxx]/[gatsby-source-apiserver]/gatsby-node.js:1:423
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
⠇ source and transform nodes
{
resolve: 'gatsby-source-apiserver', // REF: https://www.gatsbyjs.org/packages/gatsby-source-apiserver/
options: {
// Type prefix of entities from server
typePrefix: 'internal__',
// The url, this should be the endpoint you are attempting to pull data from
url: GET_DATA_URL,
method: 'get',
// Name of the data to be downloaded. Will show in graphQL or be saved to a file
// using this name. i.e. posts.json
name: `data`,
// Nested level of entities in response object, example: `data.posts`
entityLevel: `data`,
schemaType: dataSchema,
// Optionally save the JSON data to a file locally
// Default is false
localSave: false,
// Required folder path where the data should be saved if using localSave option
// This folder must already exist
path: `${__dirname}/src/assets/data/`,
// Optionally include some output when building
// Default is false
verboseOutput: true, // For debugging purposes
// Optionally skip creating nodes in graphQL. Use this if you only want
// The data to be saved locally
// Default is false
skipCreateNode: false, // skip import to graphQL, only use if localSave is all you want
entitiesArray: [{
url: GET_DATA_URL,
method: 'get',
headers: {
'Content-Type': 'application/json'
},
name: `data`,
}]
}
},
它应该正常工作。 我正在使用的软件包:
...
"gatsby-source-apiserver": "^2.1.3",
"gatsby": "^2.3.34",