equal-aqua
equal-aquaβ€’16mo ago

Query string format

Hello. I am using the fineFoods example as base. I created a new list page using another as example. It is working perfect, the only thing i see when i make a seach in the form the query string prints in a little weird manner (captured image): http://localhost:3000/leads?pageSize=10&current=1&filters[0][field]=fechaInicio&filters[0][operator]=eq&filters[0][value]=19042023&filters[1][field]=fechaFin&filters[1][operator]=eq&filters[1][value]=28042023 The get request in console is fine: /leads?_end=10&_start=0&fechaFin=28042023&fechaInicio=19042023 It is normal or i am doing something wrong? Regards.
No description
7 Replies
kapa.ai
kapa.aiβ€’16mo ago
Hi @pabloat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.aiβ€’16mo ago
---------------------- Hello! Based on the information extracts provided, I cannot determine if there is an issue with your specific implementation. However, I can provide some general guidance on how refine handles filtering in the getList method. When using the getList method in a data provider, refine sends filter query parameters to the API. The filters parameter is an array of objects, each containing a field, operator, and value. Here's an example of how filters are used in the useList hook:
const { data } = useList({
resource: "posts",
sorters: [
{
field: "id",
order: "desc",
},
],
filters: [
{
field: "title",
operator: "contains",
value: "hello",
},
],
});
const { data } = useList({
resource: "posts",
sorters: [
{
field: "id",
order: "desc",
},
],
filters: [
{
field: "title",
operator: "contains",
value: "hello",
},
],
});
Source (https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider) The URL you provided seems to be generated by refine when applying filters. It's important to note that the actual API request may have a different format, as you mentioned in your console output. If your list page is working correctly and the API request is formatted as expected, it's likely that the URL you see in the browser is just how refine internally handles filters. If you need more information or assistance, I recommend checking the refine documentation (https://refine.dev/docs) and examples (https://refine.dev/docs/examples) for further guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.aiβ€’16mo ago
<@703699805242916934> kapa.ai is still learning and improving, please let us how it did by reacting below
fair-rose
fair-roseβ€’16mo ago
Hey @pabloat, refine uses qs to parse and stringify arrays. So, we don't handle it 🀞🏻 You can find more information here: https://github.com/ljharb/qs#parsing-arrays
GitHub
GitHub - ljharb/qs: A querystring parser with nesting support
A querystring parser with nesting support. Contribute to ljharb/qs development by creating an account on GitHub.
equal-aqua
equal-aquaβ€’16mo ago
no, my question is why the query string was so "ugly" (sorry my english).
fair-rose
fair-roseβ€’16mo ago
Haha, I dont know but i think it is not ugly. How would you do it?
equal-aqua
equal-aquaβ€’16mo ago
haha, its ok, i thought i was doing something wrong