#GraphQL + GraphCMS Assistance
6 messages · Page 1 of 1 (latest)
If you console log posts in the component, does anything show?
I don’t think it’s an API problem; in all likelihood it’s something to do with my use of the map function itself. See #❓javascript message
!!js.undefined
Uncaught TypeError: Cannot read properties of undefined (reading 'name') (or a very similar message)
This means you have tried to access a property on a value that is undefined. A value could be undefined (or null) for many reasons.
// Using a variable without declaring it:
foo.name;
// Declaring a variable, but not setting a value:
let foo;
foo.name;
// Declaring a variable, but setting it to undefined explicitly...
// or returning undefined from a function or method:
let foo = undefined;
foo.name
You'll have to find the variable on which you try to access the property, and work backwards to find out why it's undefined (or null). Errors come with stack traces right underneath. It will say the exact line and position where the error occurred.
Based on the error you are mapping over an undefined variable. So posts is almost certainly empty/undefined when it comes into that component. This would be very easy to verify with a console log. You will need to trace that back and see why it is not defined.