refine
refine copied to clipboard
[DOC] Query in code tutorial not reflects api url example
Documentation issue
I'm following the tutorial documentation, and I noticed that some code does not align with the provided examples. This discrepancy may confuse users going through the tutorial.
For instance, in the getList example found here: https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider/#getlist, the API params example is given as follows:
[GET] https://api.fake-rest.refine.dev/posts?_limit=10&_page=2
However, in the code below this example, a variable is created as follows:
...
const { current = 1, pageSize = 10 } = pagination ?? {};
const query: {
_start?: number;
_end?: number;
} = {
_start: (current - 1) * pageSize,
_end: current * pageSize,
};
...
I've tested both sets of parameters in the API URL, and they both work but return different results.
Could we use the same parameters in each example, or is there any issue with this approach?
Describe the thing to improve
Params examples and code
Describe the solution (optional)
No response
Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have _start
and _end
parameters.
Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have
_start
and_end
parameters.
For consistency, you should align the code with the example URL. In this case, you can modify the code to use _limit
and _page
instead of _start
and _end
:
const { current = 1, pageSize = 10 } = pagination ?? {};
const query: {
_limit?: number;
_page?: number;
} = {
_limit: pageSize,
_page: current,
};
Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have
_start
and_end
parameters.For consistency, you should align the code with the example URL. In this case, you can modify the code to use
_limit
and_page
instead of_start
and_end
:const { current = 1, pageSize = 10 } = pagination ?? {}; const query: { _limit?: number; _page?: number; } = { _limit: pageSize, _page: current, };
This doc is referencing to simple-rest
data provider, and we are using _start
, _end
parameters in this package, see here.
So it's better to be consistent with the code in the data provider.
Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have
_start
and_end
parameters.For consistency, you should align the code with the example URL. In this case, you can modify the code to use
_limit
and_page
instead of_start
and_end
:const { current = 1, pageSize = 10 } = pagination ?? {}; const query: { _limit?: number; _page?: number; } = { _limit: pageSize, _page: current, };
This doc is referencing to
simple-rest
data provider, and we are using_start
,_end
parameters in this package, see here.So it's better to be consistent with the code in the data provider.
Ohhkk👍 I just did the change and I was just going to push the commit. So there's no need to make any changes in it? If not, then we should close the issue.
We should update generated query parts in the documentation: https://github.com/refinedev/refine/blob/master/documentation/docs/tutorial/2-understanding-dataprovider/2-create-dataprovider.md#194