Contentful logo

Contentful Community

Pulling the data

I am not able to fetch the data from the “short text - list”. I mean I had made a list of the array inside a short text. I want to fetch the data inside my app. But I can’t find that solution for how to fetch it from the contentful… Please help me on how to do that.
For example, when we are fetching the image from the contentful we use “logoImages[1].fields.file.url” then what for that array of list “”

Hi @ankit.sharma,

I haven’t tried one for multiple entries, but for single entry collection, this code should work:

const contentful = require('contentful')

const client = contentful.createClient({
  space: '<space_id>',
  environment: '<environment_id>', // defaults to 'master' if not set
  accessToken: '<access_token>'
})

client.getEntry('<entry_id>')
.then((entry) => console.log(entry.fields['<short_text_list_field_id'][0])) //0 - if you are fetching the first item in the array 
.catch(console.error) 

Cheers,
Fanny from Contentful’s Support team