从 Contentful 检索降价时的 Gatsby "NetworkError when attempting to fetch resource"
Gatsby "NetworkError when attempting to fetch resource" when retrieving markdown from Contentful
我正在使用 gatsby 入门博客模板,我已经成功地从 contentful 中获取富文本并将其显示在页面上。我现在正在尝试做同样的事情,但使用降价,但我的 graphql 查询出现错误 "NetworkError when attempting to fetch resource."。
我正在尝试按照此处的文档进行操作,因此首先我有一个长文本字段,用于在名为 "bodym" 的内容中存储降价。
我的 GraphQL 查询如下,我基本上是在尝试遵循 example。我可以从 contentful 查询降价。
但是,在尝试将其转换为可用时 HTML 我收到错误消息:
我在控制台中得到以下信息:
ERROR
The "path" argument must be of type string. Received type undefined
Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Recei ved type undefined
- validators.js:125 validateString
internal/validators.js:125:11
- index.js:68 _callee$
[faesel-blog]/[gatsby-remark-relative-images]/index.js:68:40
- index.js:5 asyncGeneratorStep
[faesel-blog]/[gatsby-remark-relative-images]/index.js:5:103
- index.js:7 _next
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:194
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:364
- new Promise
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:97
- index.js:96
[faesel-blog]/[gatsby-remark-relative-images]/index.js:96:22
- new Promise
- index.js:47
[faesel-blog]/[gatsby-remark-relative-images]/index.js:47:12
- Array.map
- index.js:46 module.exports
[faesel-blog]/[gatsby-remark-relative-images]/index.js:46:22
我的代码可以找到here。
考虑到我能够从 contentful 中检索降价。我猜问题出在 gatsby-source-contentful 插件的某个地方。感谢任何帮助!
我发现这是包依赖性的问题,代码库最初来自 gatsby starter,为了解决这个问题,我将包依赖性更改为以下内容:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.2.0",
"gatsby": "^2.3.3",
"gatsby-plugin-react-helmet": "^3.0.12",
"gatsby-plugin-sass": "^2.0.11",
"gatsby-plugin-sharp": "^2.0.32",
"gatsby-remark-images": "^3.0.10",
"gatsby-remark-relative-images": "^0.2.2",
"gatsby-source-contentful": "^2.0.47",
"gatsby-source-filesystem": "^2.0.28",
"gatsby-transformer-remark": "^2.3.8",
"node-sass": "^4.11.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.0"
},
然后升级依赖如下:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.4.0",
"gatsby": "^2.23.11",
"gatsby-plugin-react-helmet": "^3.3.6",
"gatsby-plugin-sass": "^2.3.6",
"gatsby-plugin-sharp": "^2.6.14",
"gatsby-remark-images": "^3.3.13",
"gatsby-remark-relative-images": "^0.2.3",
"gatsby-source-contentful": "^2.3.18",
"gatsby-source-filesystem": "^2.3.14",
"gatsby-transformer-remark": "^2.8.19",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^5.2.1"
}
这似乎解决了问题。
我正在使用 gatsby 入门博客模板,我已经成功地从 contentful 中获取富文本并将其显示在页面上。我现在正在尝试做同样的事情,但使用降价,但我的 graphql 查询出现错误 "NetworkError when attempting to fetch resource."。
我正在尝试按照此处的文档进行操作,因此首先我有一个长文本字段,用于在名为 "bodym" 的内容中存储降价。
我的 GraphQL 查询如下,我基本上是在尝试遵循 example。我可以从 contentful 查询降价。
但是,在尝试将其转换为可用时 HTML 我收到错误消息:
我在控制台中得到以下信息:
ERROR
The "path" argument must be of type string. Received type undefined
Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Recei ved type undefined
- validators.js:125 validateString
internal/validators.js:125:11
- index.js:68 _callee$
[faesel-blog]/[gatsby-remark-relative-images]/index.js:68:40
- index.js:5 asyncGeneratorStep
[faesel-blog]/[gatsby-remark-relative-images]/index.js:5:103
- index.js:7 _next
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:194
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:364
- new Promise
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:97
- index.js:96
[faesel-blog]/[gatsby-remark-relative-images]/index.js:96:22
- new Promise
- index.js:47
[faesel-blog]/[gatsby-remark-relative-images]/index.js:47:12
- Array.map
- index.js:46 module.exports
[faesel-blog]/[gatsby-remark-relative-images]/index.js:46:22
我的代码可以找到here。
考虑到我能够从 contentful 中检索降价。我猜问题出在 gatsby-source-contentful 插件的某个地方。感谢任何帮助!
我发现这是包依赖性的问题,代码库最初来自 gatsby starter,为了解决这个问题,我将包依赖性更改为以下内容:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.2.0",
"gatsby": "^2.3.3",
"gatsby-plugin-react-helmet": "^3.0.12",
"gatsby-plugin-sass": "^2.0.11",
"gatsby-plugin-sharp": "^2.0.32",
"gatsby-remark-images": "^3.0.10",
"gatsby-remark-relative-images": "^0.2.2",
"gatsby-source-contentful": "^2.0.47",
"gatsby-source-filesystem": "^2.0.28",
"gatsby-transformer-remark": "^2.3.8",
"node-sass": "^4.11.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.0"
},
然后升级依赖如下:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.4.0",
"gatsby": "^2.23.11",
"gatsby-plugin-react-helmet": "^3.3.6",
"gatsby-plugin-sass": "^2.3.6",
"gatsby-plugin-sharp": "^2.6.14",
"gatsby-remark-images": "^3.3.13",
"gatsby-remark-relative-images": "^0.2.3",
"gatsby-source-contentful": "^2.3.18",
"gatsby-source-filesystem": "^2.3.14",
"gatsby-transformer-remark": "^2.8.19",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^5.2.1"
}
这似乎解决了问题。