Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'length' of undefined

See original GitHub issue

Issue Description

I just installed a fresh instance of WP and the starter.

The home page pulls up no problem but…

For some reason when I click on a post I am getting this error.

Server Error TypeError: Cannot read property ‘length’ of undefined

` 147 | 148 | const { categories, postId } = post;

149 | const category = categories.length && categories[0]; | ^ 150 | let { name, slug } = category; 151 | 152 | return {`

I have not added anything else to the starter (other than the graphql endpoint). I have not added any posts new posts. I added only one additional category for testing.

Is there a step I am missing?

Here is the WP install:


Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

colbyfayockcommented, May 1, 2021

Fixed via #156

doingandlearningcommented, Apr 30, 2021

Very happy to do this.

Confirmed with the WPGraphQL team that this was an issue.

Screenshot_20210430_171508_com Slack

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'length') - TrackJS
TypeError is a subset of JavaScript Error that is thrown when code attempts to do something that does not exist on the target...
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >
[SOLVED] Cannot Read Property 'length' of Undefined in JS
To fix the “cannot read property 'length' of undefined” error, perform an undefined check on the variable before accessing the length property ......
Read more >
Cannot read property length of undefined - Stack Overflow
The error means that what ever element is returned by getElementById('WallSearch') , it does not have a value property. Every form field has...
Read more >
TypeError: Cannot read property 'length' of Undefined in JS
The "Cannot read property 'length' of undefined" error occurs when accessing the length property on an undefined value. To solve the error, make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found