Hi,
In Contentful we have created a space, let say ABC and within that we have created two environments, like master and develop.
ABC
We have created API key and selected develop environment as well.
Problem:
we are unable to access the contentful data from develop environment.
Hey @vigneshgowrabathuni, there's not enough information here to help you. Could you fill out the issue template?
Hi @m-allanson
Code Sample for Java Script:
const contentful = require('contentful')
const client = contentful.createClient({
space: '<space_id>',
environment: '<environment_id>', // defaults to 'master' if not set
accessToken: '<content_delivery_api_key>'
})
client.getSpace()
.then((space) => console.log(space))
.catch(console.error)
Code sample for gatsby contentful plugin:
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id`,
accessToken: `your_access_token`,
},
},
];
In Javascript we can mention respective environment let say master or stage or develop
But in gatsby contentful plugin, how we can access specific environment data,
I have tried like this, but still i am unable to access data.
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id`,
**environment: '<environment_id>', // defaults to 'master' if not set**
accessToken: `your_access_token`,
},
},
];
Here the challenge is I am unable to access data from develop environment, is there any alternative way to access data from specific environment?
Hey @m-allanson and @vigneshgowrabathuni,
Just to explain Here, we introduced recently a new feature at Contentful, so you can have different environments for your space think of it like branches.
master is the default environment so that's why you can only see that, to get content from a different environment you need to tell the SDK that you are using a different one. One problem here is that the sync API, unfortunately, is only available in the master environment.
This will hopefully change soon.
Best,
Khaled
Ah that explains it, thanks for the update @Khaledgarbaya! What's the best way to track updates to the sync API?
Things might change very soon hopefully, I am discussing this with our backend team.
Expect an update soon hopefully with a PR
Thanks for the update @Khaledgarbaya 馃槃
So I had a conversation with our backend team and they just enabled the feature for environments
here is a PR to add support for it.
Hey @m-allanson this is no longer blocked
Fast work, thanks @Khaledgarbaya :)
This is awesome @kaihendry!