Skip to content

How should I structure dataProvider and resources for nested API structures? #6595

Answered by BatuhanW
ms-bang asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @ms-bang, resource object also accepts parent field, you can utilize that one.

export const resources = [
  {
    name: 'users',
    list: '/users',
  },
  {
    name: 'company-managements',
    hide: true // probably we don't want to show it in the sidebar.
  },
  {
    name: 'companies',
    list: '/company-managements/companies', // you can still keep this nested, since it's path on the client side.
    meta: {
      parent: 'company-managements',
    }
  },
  {
    name: 'departments',

    list: '/company-managements/companies/:companyId/departments',
    meta: {
      parent: 'companies',
    },
  },
];

// In your data provider
console.log(meta.parent)
console.log(meta.compan…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ms-bang
Comment options

@ms-bang
Comment options

Answer selected by BatuhanW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants