Skip to content

Nested query - How to fetch categories of each product #230

Answered by logeshswell
agsmartwolf asked this question in Help
Discussion options

You must be logged in to vote

I found an answer to your query. Please check and let me know if you face any other issues.

First you need to setup the permissions as follows:

{
  "permissions": {
    "categories": {
      "fields": [
        "products.name",
        "products.slug",
        "products.price",
        "products.categories",
        "products.categories.parent"
      ],
      "expands": {
        "products": {
          "url": "/products",
          "params": {
            "categories": "id"
          },
          "data": {
            "expand": ["categories.parent"]
          }
        }
      }
    }
  }
}

Secondly, you can use swell-js to query as follows:

let categoryDetails = await swell.categories.get(

Replies: 2 comments 20 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
20 replies
@logeshswell
Comment options

@agsmartwolf
Comment options

@logeshswell
Comment options

@logeshswell
Comment options

Answer selected by logeshswell
@agsmartwolf
Comment options

@agsmartwolf
Comment options

@agsmartwolf
Comment options

@agsmartwolf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
4 participants