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

contentful is undefined when importing via ES6 style #2241

Open
y-lobau opened this issue Apr 2, 2024 · 1 comment
Open

contentful is undefined when importing via ES6 style #2241

y-lobau opened this issue Apr 2, 2024 · 1 comment

Comments

@y-lobau
Copy link

y-lobau commented Apr 2, 2024

The documentation states:

import contentful from 'contentful-management'
const client = contentful.createClient(
  {
    // This is the access token for this space. Normally, you get the token in the Contentful web app
    accessToken: 'YOUR_ACCESS_TOKEN',
  },
  { type: 'plain' }
)

When running this code from within the Contentful App (react), the contentful variable is undefined.

image

I was able to make it work with the following instead:

import { createClient } from "contentful-management";
const client =createClient...

Node.js: v21.7.1
contentful-management: 11.24.3

@dvejmz
Copy link

dvejmz commented May 13, 2024

I can confirm I have the same issue in version 11.25.3 of the contentful-management package and that @y-lobau 's workaround works for me too.

It would be good to have this addressed though as the ES6 import example in the documentation does not work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants