refine icon indicating copy to clipboard operation
refine copied to clipboard

[DOC] I want to remove ?& when calling API in useTable

Open SeungChans opened this issue 1 year ago • 6 comments

Documentation issue

I want to remove ?& when calling API in useTable

Describe the thing to improve

I want to remove the ?& when calling the api in useTable and use the custom query I created.

Describe the solution (optional)

No response

SeungChans avatar Dec 11 '23 05:12 SeungChans

Hello @SeungChans can you provide more details? Minimal reproducible example would be great, but you can also let us know which data provider you are using, your example code and generated query.

BatuhanW avatar Dec 11 '23 07:12 BatuhanW

Hello, if you type the code below, in the request api baseUrl/users?& is called like this I want to paste the query I want in baseUrl/users

const { tableProps } = useTable({ resource: 'users', hasPagination: false, });

SeungChans avatar Dec 11 '23 07:12 SeungChans

Request is generated by data provider, so we can't know the reason if you don't let us know which data provider you are using.

BatuhanW avatar Dec 11 '23 07:12 BatuhanW

<Refine dataProvider={dataProvider( 'https://test.com' )} routerProvider={routerProvider} syncWithLocation={false} resources={[ { name: 'refine', list: '/refine', }, ]} > <App {...props} /> </Refine>

import dataProvider from '@refinedev/simple-rest';

I am using the same content as above

SeungChans avatar Dec 11 '23 07:12 SeungChans

Thanks for the information @SeungChans.

Issue arise from this line: https://github.com/refinedev/refine/blob/fba8f7370057fa8d4c27de6b9432fec4ccada268/packages/simple-rest/src/provider.ts#L50

We are adding ? and &, without checking the existence of queries and filters. We need to manually add ? and/or & depending on the existence of queries and filters.

We are open to contributions for this issue, should be easy to fix! 🚀

@SeungChans if you need a quick solution, you can swizzle the data provider and fix it locally. https://refine.dev/docs/tutorial/understanding-dataprovider/swizzle/#how-do-you-use-swizzle-to-create-an-data-provider

BatuhanW avatar Dec 11 '23 08:12 BatuhanW

Hey @BatuhanW I tried to resolve this with a util function here. Please let me know if that's the correct approach and i'll proceed with updating the code everywhere and in docs too. Thanks

amanzrx4 avatar Dec 15 '23 10:12 amanzrx4