Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
List content entries matching specific criteria using the contentful content delivery API
var contentful = require('contentful');
var spaceId = 'someSpaceId';
var accessToken = 'someAccessToken';
var contentTypeId = 'someContentTypeId';
var client = contentful.createClient({
space: spaceId,
accessToken: accessToken,
secure: true,
host: 'cdn.contentful.com'
});
client.entries({
'content_type': contentTypeId,
'fields.pageId': 'all',
'fields.geoCode': 'all'
}, function(err, entries) {
if (err) { console.log(err); return; }
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
console.log('id: ' + entry.sys.id);
console.log('name: ' + entry.fields.name);
console.log('pageId: ' + entry.fields.pageId);
console.log('--------')
}
});
id: someId1
name: promo-3
pageId: all,page2,page3
--------
id: someId2
name: promo-2
pageId: all,page5
--------
id: someId3
name: promo-1
pageId: all
--------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment