-1

Is it possible to, for example, change the "q" query key in the AutocompleteInput?

The default { "q": "foobar" } doesn't work with my API where "q" would be correspondent to a model key, e.g productName to make the filtering.

EDIT: (CLOSED) Realizing this isn't really AoR's responsibility I've opted to instead modify my restClient to handle a "q" keyed request.

EDIT 2: This can also be done in the view layer by using the filterToQuery prop on ReferenceInput/ReferenceArrayInput to modify the query sent to your restClient

Emil Hernqvist
  • 188
  • 1
  • 7

1 Answers1

0

You can handle this at the client level as well. Just use a custom Rest Client or use a RestClient wrapper to intercept the call to your API and format the request URL depending on the value of the q filter.

https://marmelab.com/admin-on-rest/RestClients.html#decorating-your-rest-client-example-of-file-upload

https://marmelab.com/admin-on-rest/RestClients.html#writing-your-own-rest-client

Hope this helps.

kunal pareek
  • 1,285
  • 10
  • 21
  • This is what I ended up doing, I realized this was the way to go just moments after posting the question... Sorry! Hopefully this thread can help others find the way I did though. – Emil Hernqvist Dec 08 '17 at 13:31
  • Actually, when working on other things I realized the `filterToQuery` prop on ReferenceArrayInput was what I was looking for originally. – Emil Hernqvist Dec 11 '17 at 13:09
  • Hmm AOR is moving fast. The above was the only sensible solution I found for things just 3 months ago. – kunal pareek Dec 12 '17 at 05:15