colossal-harlequinC
Refine3y ago
3 replies
colossal-harlequin

REST data provider and nested routes

I'm quite heavily using nester routes, such as http://localhost:5173/organization/F16CC4C4-9C83-41E1-8A79-A8108A10DD98/campaigns with a REST API. I've already swizzled the data provider and can see that the API call hooks, such as getList: async ({ resource, pagination, filters, sorters, meta }) return the resource as organization/:organizationId/campaigns and there is organizationId property inside of
meta
.

I’ve written a method that “fixes” the path, looks something like
function fixResoureceParams(resource: string, meta: MetaQuery | undefined): string {
  return resource.replace(":organizationId", meta?.organizationId ?? "???");
}

getList: async ({ resource, pagination, filters, sorters, meta }) => {
    resource = fixResoureceParams(resource, meta); // my change
    const url = `${apiUrl}/${resource}`;
    // ....
}

so I got it to work.

Just wanted to confirm that this is indeed not currently not supported by the REST API provider and that I’m not doing something wrong. Thanks!
Was this page helpful?