List entries by content type
Log in to add to favouritesCall the entries.list() method in our delivery client to get a paged list of entries of a given content type
Call signatures
list(contentTypeId: string): Promise<PagedList<Entry>>
list(options: EntryListOptions): Promise<PagedList<Entry>>
Parameters
Name | Type | Description |
---|---|---|
contentTypeId | string | The id of the content type |
options | EntryListOptions | An object specifying the content type id, language, page options, ordering, fields to return and linkDepth. |
Returns
A Promise that will resolve with a Paged List of Entry
Example
Get a list of entries of a given content type API ID
// Using TypeScript, or ES Module await syntax
const entryList = await client.entries.list('<content-type-id>');
for (const entry of entryList.items) {
console.log(entry.entryTitle);
}
Get a list of entries of a given content type API ID
// Using Common JS promise callback syntax
client.entries.list('<content-type-id>')
.then(function (entryList) {
entryList.items.forEach(item => (
console.log(item.entryTitle)
))
});
Example - using entry list options
Get only the title and overview fields of the French entry variations resolving linked content to a depth of 2
// Using TypeScript, or ES Module await syntax
const entryList = await client.entries.list({
id: '<content-type-id>',
language: 'fr-FR',
linkDepth: 2,
fields: ['title', 'overview']
})
for (const entry of entryList.items) {
console.log(entry.title);
console.log(entry.overview);
}
Get only the title and overview fields of the French entry variations resolving linked content to a depth of 2
// Using Common JS promise callback syntax
client.entries
.list({
id: '<content-type-id>',
language: 'fr-FR',
linkDepth: 2,
fields: ['title', 'overview']
})
.then(function (entryList) {
entryList.items.forEach(item => (
console.log(item.title);
console.log(item.overview);
))
});