graphql - Nuxt apollo TypeError:无法读取未定义的属性“节点”
问题描述
我正在使用 NuxtJS Vue-apollo 从带有 CPT 的 WordPress 获取 GraphQL 数据。
NuxtJS 中有几个页面分别列出posts
,CPT1
和CPT2
. 如果我重新加载页面,我可以显示所有帖子。但是,如果我从列出posts
到CPT1
或任何其他组合的页面转到,我会收到以下错误TypeError: Cannot read property 'nodes' of undefined
。
即使我回去,第一页也可以列出帖子,而所有其他页面都会出错。查询如下所示:
query queryPosts {
posts {
nodes {
id
title
modified
date
slug
uri
featuredImage {
node {
id
sourceUrl(size: THUMBNAIL)
altText
}
}
}
}
}
和:
query queryCPT1 {
cpt1 {
nodes {
id
title(format: RENDERED)
uri
problemer { <- this is an ACF field
cardTitle
cardImage {
id
sourceUrl(size: LARGE)
}
}
}
}
}
我已经尝试在页面上显示 JSON 数据原始数据,并且有效。但是,如果我尝试在结果 JSON 中指定任何内容,则会收到错误消息。
我怎样才能解决这个问题?
解决方案
推荐阅读
- ios - 加载失败,错误域=NSURLErrorDomain 代码=-999 “已取消”
- nativescript - 在迁移到 nativescript 6.0 后修复“找不到类:android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener”
- reactjs - 需要未知模块“未定义”
- google-cloud-dataflow - 为 10 分钟窗口指定正确触发 + 5 分钟延迟缓冲区仅产生 1 个结果
- python - 如何在excel表之间切换?
- php - 即使在页面刷新后 iframe 视频也不会停止运行
- c# - 在 Visual Studio 的 c#projects 中工作但在 Python 中不工作的 xml 肥皂代码
- ubuntu - 运行“./worldserver”显示“地图文件'./maps/0004331.map':不存在!” 错误
- javascript - 删除值时将输入背景颜色更改为白色
- java - 将数据从一个活动传递到另一个活动并设置为调用它的特定 EditText 字段