Last active
August 29, 2015 14:07
-
-
Save jpotts/69b212d460091e8c8e85 to your computer and use it in GitHub Desktop.
List content entries matching specific criteria using the contentful content delivery API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('--------') | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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