How to usw filter_querys in Nuxt.js

Hey Storyblok, I am trying to implement filtering by categories for a portfolio project. I am using a key with single-select option for the categories.

I tried the following without any success:

return context.app.$storyapi.get(`cdn/stories/projects`, {
	version: version,
	cv: context.store.state.cacheVersion,
    resolve_relations: "project_preview.project",
    // Attempt to use filter_query
    filter_query: "[categories][in]=office"

And:

return context.app.$storyapi.get(`cdn/stories/projects`, {
	version: version,
	cv: context.store.state.cacheVersion,
    resolve_relations: "project_preview.project",
    // Attempt to use filter_query
    filter_query: "[page_project.categories][in]=office"

With »page_project« being the component name and »office« the value and name of the single-option key.

Could you help me out?

Hello Mato,

nice to have you in our forum.
You can take a look at this example that shows how you need to use it in your code:

// Get all news and author contents
client.get('cdn/stories', {
    version: 'draft',
    filter_query: {
      component: {
        in: 'news,author'
      }
    }
  }).then((res) => {
    console.log(res.data.stories)
  })

You can find more examples here:
https://github.com/storyblok/storyblok-js-client

Hallo Hannes, thanks for the warm welcome!

Oh I see, so I can’t filter_query cdn/strories/something_else but only cdn/stories!

Sorry for replying this late!

You’re welcome Mato!
No problem. Yes the filter_query can only be used on stories. You can take a look at the documentation: https://www.storyblok.com/docs/api/content-delivery#core-resources/stories/retrieve-multiple-stories
Parameters like starts_with are really helpful as well when you have folders and know where you want to search for certain stories containing keywords in their fields.

That makes absolutely sense now!

Sorry, complete noobie to CMS…

Thanks again!

Please, don’t worry about that.
You’re welcome!