Not getting category_index property in the products list on frontend

I am fetching the products list by using swell front-end APIs - https://developers.swell.is/frontend-api/products

In the developer console, I checked that product model contains a category_index key which contains a list of category ids. I was getting this field earlier, but since yesterday, the frontend-API has been returning my error saying that I don't have permission to expand this field.

I'm attaching console error log and my code that I've been using below.



Answers

  • Hey @Gaurav Pandey I consulted one of our engineers and was advised that we do not allow to expand category_index.

    Instead, what should you do is to expand the categories.

    Additionally, you can only access category_index from the developer console or backend API, or explicitly grant access to it.

    Or you can collect the product category IDs from the response:

    Β Β const ids = (product.categories || []).map(category => category.id);


    Lastly, what you should do is to remove query.expand = ['category_index'] from your code to make it working again.

  • Gaurav Pandey
    edited September 8

    Hi Jesse, thanks for your reply.

    I was indeed getting this category_index in some of the responses while using frontend sdk. So, I guess some issue with the swell. Please check that with your engineering team.

  • @Gaurav Pandey can you share which request gets the category_index in the response and which response doesn't? Or was it intermittent?

Sign In or Register to comment.