The Contentful npm package provide access to all the functionality from the API. In my case, I know the ID for the entry I want, but need to retrieve the data for a non-default locale and I can't see any way to pass the locale option. My query looks like this:
const { createClient } = require('contentful');
const contentfulClient = createClient({
accessToken: 'xxxxxxxx',
space: 'xxxxxxx',
});
const entry = contentfulClient
.getEntry('xxxxxx')
.catch(console.error);
I know I could do the following:
const data = await contentfulClient
.getEntries({
content_type: 'xxxxxx'
locale: 'cy',
'sys.id': xxxxx,
})
.catch(console.error);
const [entry] = data.items;
But this requires the content type and returns an array of entries, which seems counter intuitive when I know the exact entry I want. Am I missing something? Seems like a logical thing to expect it to do.