Storyblok Javascript client calling fields

Hi there,

I was wondering if there is a way to do a getAll request in the Javascript client and only include title and slug? According to the API docs (https://www.storyblok.com/docs/api/content-delivery#core-resources/stories/retrieve-multiple-stories) there’s a method of setting excluded fields only. There’s a LOT of them so that’s a bit annoying. A field whitelist would be equally as useful, if not more useful.

I’m generating a list of pages in Next.js via getStaticPaths so having this feature for just a lookup instead of pulling down the whole structure would have a big performance benefit.

This is an example of what I’m doing:

export async function getStaticPaths() {
  const programs = await StoryblokService.getAll('cdn/stories', {
    filter_query: { component: { in: 'program' },
    excluding_fields: 'title'
  }})
  console.log(programs);
  return {
    paths: [
      { params: { slug: '' } }
    ]
  };
}

On a separate note it seems that I get a 500 error (with no other information) when I include excluding_fields, so that’s a completely separate question I suppose.

Thanks,

David

Hello David,

nice to see you here on our forum!

I think that you’re searching for the links API:
https://www.storyblok.com/docs/api/content-delivery#core-resources/links/retrieve-multiple-links

It will give you basic information about the stories and even folders of your space.
Here is an example response from the links API:

{
  "links": {
    "ac0d2ed0-e323-43ca-ae59-5cd7d38683cb": {
      "id": 107350,
      "slug": "posts/my-third-post",
      "name": "My third post",
      "is_folder": false,
      "parent_id": 107348,
      "published": true,
      "position": -20,
      "uuid": "ac0d2ed0-e323-43ca-ae59-5cd7d38683cb",
      "is_startpage": false
    },
    "a91440ee-fd57-4ee3-83cf-d49d217ae919": {
      "id": 107349,
      "slug": "posts/my-second-post",
      "name": "My second post",
      "is_folder": false,
      "parent_id": 107348,
      "published": true,
      "position": -10,
      "uuid": "a91440ee-fd57-4ee3-83cf-d49d217ae919",
      "is_startpage": false
    },
    "bfea4895-8a19-4e82-ae1c-1c591dce3094": {
      "id": 107351,
      "slug": "posts/my-first-post",
      "name": "My first Post",
      "is_folder": false,
      "parent_id": 107348,
      "published": true,
      "position": 0,
      "uuid": "bfea4895-8a19-4e82-ae1c-1c591dce3094",
      "is_startpage": false
    }
  }
}

With best regards
Hannes