lotas / contentful-graph

Visual representation of contentful content models in form of graphs
https://www.contentful.com/blog/2017/08/08/how-to-quickly-visualize-your-content-model/
MIT License
59 stars 6 forks source link

space.getEnvironment is not a function error #18

Closed amandasage closed 3 years ago

amandasage commented 4 years ago

Hey lotas,

I'm having a Contentful user running into the attached error after following the instructions on the plugin page space.GetEnvironment is not a function.

Thank you!

Update: Was able to resolve

lotas commented 4 years ago

Oops. Late to the party :) Good!

x-stefan commented 3 years ago

BUT HOW? Please share your solution the next time, because I have the same issue and need to solve it 😉

lotas commented 3 years ago

BUT HOW? Please share your solution the next time, because I have the same issue and need to solve it 😉

My guess is that credentials are incorrect. Depending on the type of keys you have (management or distribution), can you please debug import-distribution.js and import-management.js to see if client.getSpace(spaceId) returns anything valid and spaceId is set properly?

x-stefan commented 3 years ago

I just figured out it works with the CMA Token, but doesn't seem to work with my CDA Token.

With the CDA Token, client.getSpace() returns me an object like this:

{
  sys: { type: 'Space', id: 'XXX' },
  name: 'XXX',
  locales: [ { code: 'de', default: true, name: 'German', fallbackCode: null } ]
}
lotas commented 3 years ago

huh! that might be a problem indeed. Checked documentation, it doesn't have getEnvironment() function anymore.

For now I would recommend using CMA way.. will check if this is something that can be fixed, or CDA is no longer suitable for this kind of metadata fetching

Swissbite commented 3 years ago

28 fixes this issue

lotas commented 3 years ago

@Swissbite fixed this issue, PR merged. Thanks!