Skip to content

Instantly share code, notes, and snippets.

@jpotts
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpotts/69b212d460091e8c8e85 to your computer and use it in GitHub Desktop.
Save jpotts/69b212d460091e8c8e85 to your computer and use it in GitHub Desktop.
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