GatsbyCentral / gatsby-starter-wordpress

LOOKING FOR MAINTAINER - - - A GatsbyJS starter template that leverages the WordPress API, ACF and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot convert undefined or null to object

danny-waite opened this issue · comments

Description

when baseUrl: 'engineersf.com in gatsby-config.js:

  TypeError: Cannot convert undefined or null to object
  
  - Function.keys
  
  - fetch.js:534 getValidRoutes
    [engineersf]/[gatsby-source-wordpress]/fetch.js:534:26
  
  - fetch.js:148 fetch
    [engineersf]/[gatsby-source-wordpress]/fetch.js:148:23
  
  - next_tick.js:68 process._tickCallback
    internal/process/next_tick.js:68:7

when run with baseUrl: 'wpdemo.gatsbycentral.com' that comes with the wordpress starter it works.

strangely allRoutes.data at fetch.js:534 is not an object and appears to be a json string, which I suspect is the root cause.

Steps to reproduce

https://github.com/danny-waite/engineersf.com

Environment

System:
OS: macOS 10.14.3
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 76.0.3809.132
Safari: 12.0.3
npmPackages:
gatsby: ^2.15.14 => 2.15.14
gatsby-awesome-pagination: ^0.3.3 => 0.3.4
gatsby-plugin-lodash: ^3.1.7 => 3.1.7
gatsby-plugin-netlify: ^2.1.12 => 2.1.12
gatsby-plugin-purgecss: ^4.0.1 => 4.0.1
gatsby-plugin-react-helmet: ^3.1.7 => 3.1.7
gatsby-plugin-sass: ^2.1.14 => 2.1.14
gatsby-plugin-sharp: ^2.2.21 => 2.2.21
gatsby-remark-images: ^3.1.21 => 3.1.21
gatsby-source-filesystem: ^2.1.22 => 2.1.22
gatsby-source-wordpress: ^3.1.31 => 3.1.31
gatsby-transformer-remark: ^2.6.22 => 2.6.22
gatsby-transformer-sharp: ^2.2.14 => 2.2.14
npmGlobalPackages:
gatsby-cli: 2.7.47

I'm also having this exact issue

Same as #49, this is caused by the configuration of the WordPress site. I'll copy my comment from #49.

This is a tough issue. The produced GraphQL schema depends on what your WordPress config looks like. If you have a single post with a featured image, then the post schema gets a featured image field, if not, then it doesn't. Bottom line, you need to carefully setup WordPress to match our demo site's config. We've done our best to document that in the README. Very open to PRs which improve the readme, or add specific tests / better errors to make this stuff clearer.

I'll close this issue for the same reason as #49, it's not caused by this starter, but the WordPress site.