TypeError: Cannot read property 'Title' of undefined #30186
Unanswered
jordan-miguel
asked this question in
Help
Replies: 3 comments 6 replies
-
Does the query work in graphiql?
…On Wed, Mar 10, 2021, 4:28 PM Jordan Miguel ***@***.***> wrote:
Issue
I can't successfully render my queried data inside of my component.
Steps to reproduce
1. I test my graphQL query that will be used to pull in data from my
CMS (*sanity*)
2. I attempt to render this in my component
3. I run gatsby develop
4. I can see TypeError: Cannot read property 'Title' of undefined
error on my browser
I am using these docs
<https://www.gatsbyjs.com/docs/recipes/querying-data/>as a reference.
Code
export const query = graphql`
query {
allSanityPosts {
edges {
node {
Title
}
}
}
}
`;
const singlePost = ({ data }) => (
<Layout>
<Header />
<div>
<h1>{data.post.Title}</h1>
</div>
</Layout>
)
export default singlePost
Error
[image: Screenshot 2021-03-10 at 23 27 50]
<https://user-images.githubusercontent.com/14114089/110711925-425a0380-81f8-11eb-9231-2baf09a2bf37.png>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#30180>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAARLB6A4W3DR47FESYXUZ3TC76DHANCNFSM4Y7DDA6A>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes it does :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
hey @jordan-miguel - i think you need to change from Also, i think you can shorten your query from this: export const query = graphql`
query {
allSanityPosts {
edges {
node {
Title
}
}
}
}
`; to this: export const query = graphql`
query {
allSanityPosts {
nodes {
Title
}
}
}
`; |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue
I can't successfully render my queried data inside of my component.
Steps to reproduce
gatsby develop
TypeError: Cannot read property 'Title' of undefined
error on my browserI am using these docs as a reference.
Code
Error
Beta Was this translation helpful? Give feedback.
All reactions