TypeError: can't access property "allWordpressPost", data is undefined
Anohjp opened this issue · 2 comments
Anohjp commented
Hi,
I tried your tutorial on LIST-POST, but I get the following error: TypeError: can't access property "allWordpressPost", data is undefined
Here is my code:
import React, { Component } from "react"
import Link from "gatsby"
import PropTypes from "prop-types"
class Actualites extends Component {
render() {
const data = this.props.data
return(
<div>
<h1>Posts</h1>
{data.allWordpressPost.edges.map(({node}) => (
<div key={node.slug} className={"post"} style={{ marginBottom: 50 }}>
<Link to={'post/' + node.slug}>
<h3>{node.title}</h3>
</Link>
<div className={"post-content"} dangerouslySetInnerHTML={{__html: node.excerpt}} />
{node.date}
</div>
))}
</div>
)
}
}
Actualites.propTypes = {
data: PropTypes.object.isRequired,
edges: PropTypes.array,
}
export default Actualites
export const pageQuery = graphql`
query postsQuery{
allWordpressPost{
edges{
node{
title
slug
date(formatString: "MMMM DD, YYYY")
}
}
}
}
`
ujjwalkrishna commented
Hey, replace "allWordpressPost" with "allWpPost" everywhere.
sinisteralex commented
I tried swapping allWordpressPost with allWpPost - did not work.
I am not sure how to proceed with this currently.