Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gatsby-source-medium] TypeError: Cannot read property 'filter' of undefined #2291

Closed
kbrgl opened this issue Sep 30, 2017 · 11 comments
Closed
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@kbrgl
Copy link
Contributor

kbrgl commented Sep 30, 2017

I'm trying to use gatsby-source-medium with a user account. Publications work fine, but I get an error with user accounts. The API response doesn't seem to possess payload.posts, which gatsby-source-medium expects.

gatsby develop outputs the following:

success delete html files from previous builds — 0.012 s
success open and validate gatsby-config.js — 0.005 s
success copy gatsby files — 0.024 s
success onPreBootstrap — 0.018 s
⠄ source and transform nodesTypeError: Cannot read property 'filter' of undefined
    at /Users/kabir/src/website/node_modules/gatsby-source-medium/gatsby-node.js:79:36
    at Array.map (<anonymous>)
    at _callee$ (/Users/kabir/src/website/node_modules/gatsby-source-medium/gatsby-node.js:71:23)
    at tryCatch (/Users/kabir/src/website/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/Users/kabir/src/website/node_modules/regenerator-runtime/runtime.js:299:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/kabir/src/website/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/Users/kabir/src/website/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/kabir/src/website/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Here's my gatsby-config.js

const metadata = require('./metadata')

module.exports = {
  siteMetadata: {
    ...metadata,
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    {
      resolve: 'gatsby-plugin-typography',
      options: {
        pathToConfigModule: 'src/utils/typography.js',
      },
    },
    {
      resolve: 'gatsby-source-medium',
      options: {
        username: '@kbrgl',
      },
    },
  ],
}

Reproducing

Change the username from smartive to an actual username (e.g. @kbrgl) in gatsby-config.js of the using-medium example

@sebastienfi
Copy link
Contributor

Hello @kbrgl Could you please build a small reproduction site for us to check out and upload to a Git repo ? That way it's way quicker to reproduce your error and solve it ;)

@sebastienfi sebastienfi added the type: bug An issue or pull request relating to a bug in Gatsby label Oct 1, 2017
@PerrySetGo
Copy link

This feels related - I can't actually retrieve info. I'm only trying to get my stories from my own medium account. I get this error:

success delete html files from previous builds — 0.006 s
success open and validate gatsby-config.js — 0.004 s
success copy gatsby files — 0.058 s
TypeError: Cannot convert undefined or null to object
    at _callee$ (C:\Users\Perry\Desktop\perrysetgo30\tutorial-part-one\node_modules\gatsby-source-medium\gatsby-node.js:62:37)

This is my gatsby-config.js

[...]
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name:`src`,
        path: `${__dirname}/src/`,
      }
    },
    {
    resolve: `gatsby-source-medium`,
    options: {
      username: `@perrysetgo`
      }
    },
[...]

Some logging around line 62 of the gatsby-node.js for the plugin seems to suggest that json.payload.references.Collection is not a thing - but I don't know this API well enough to really debug from here. Any help would be super appreciated getting this to work.

I'm really enjoying working with gatsby, it's awesome and making things come together for my new site build so fast!

@KyleAMathews
Copy link
Contributor

@PerrySetGo simple reproduction sites are the best way to get help 👍 this is a new source plugin so not well tested yet.

@kbrgl
Copy link
Contributor Author

kbrgl commented Oct 2, 2017

Okay, I have a repo up at kbrgl/gatsby-issue-2291 to reproduce. (It's just the using-medium example with the username line changed to a user account).

@ptcampbell
Copy link

ptcampbell commented Oct 18, 2017

Did you find the answer to this one? Came across the same problem.

@kbrgl
Copy link
Contributor Author

kbrgl commented Oct 18, 2017

@ptcampbell nothing so far

@KyleAMathews
Copy link
Contributor

Looks like this PR fixes this issue perhaps? #2515

Would love feedback on the PR from some people in this issue!

@kbrgl
Copy link
Contributor Author

kbrgl commented Oct 19, 2017

@KyleAMathews that does seem like a fix. I'll try it out.

@amandeepmittal
Copy link
Contributor

I am getting the same error. Any fix for it?

@aaronklaser
Copy link

try changing @ to %40

@KyleAMathews
Copy link
Contributor

Fixed in #3623

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

8 participants