After several days of iterating around formatting and variables, I am still struggling to get this code to run and keep getting various errors similar to "Cannot read properties of undefined (reading 'map')"
I am only just setting out with the basics of Javascript and Gatsby so I could be missing an absolute howler? Go easy on me.
import React from "react"
import { graphql } from "gatsby"
//export default function Home() {
// return <div>Hello world!
//<p>Is this working?</p>
//<h1>{process.env.AIRTABLE_API_KEY}</h1>
//<p>Is this working 2?</p>
// </div>
//
//}
export default ({data}) => {
const allAirtableData = data.allAirtable.nodes;
console.log(allAirtableData)
return (
<div>
<h1>'Hello World'</h1>
{
allAirtableData.map((node) => (
<p>
<img src={node.data.Model_Type} alt="hills something" />
<a href={`/${node.recordID}`}>Click Here</a>
</p>
))
}
</div>
)
}
export const query = graphql`
query AirtableQuery {
allAirtable {
edges {
node {
recordId
data {
Model_Type
}
}
}
}
}
`