Multiple possible inputs for API endpoint
This is definitely basic…
I have a table that has several fields that are table references. In my app there are times when I'll want to query that table with one or more of those table reference fields as a filter. Is it best practice to setup a single endpoint that has all possible input parameters, and setup the query logic to ignore empty parameters?
When I tried creating a new endpoint with just one of the input parameters, I got an error that said the name was already used (I copied the naming convention "table_name/{inputfield_id}"). Not seeing one in my list of existing endpoints. So this leads to my best practice question.
TIA
Best Answer
-
Hi @EricP you are correct, it sounds like one endpoint with "ignore empty values" used in the query conditions is the way to go.
In regards to the naming issue, please see this section of our documentation for more details and let me know if we can clarify anything.
Answers
-
Hello @EricP,
Not sure if I got your question right, but I am going to give it a try.
I guess you tried having more than one endpoints, which with one way or the other were serving the same purpose, with small differences based on the input.
In general, the best practice is considered to avoid having the frontend of your application decide what endpoint it should use based on some factors.
So, according to that, it is best to useis_null
and/oris_empty
Xano filters, to create a condition with different responses based on the inputs. -
Thanks for the replies. The last section of the reference documentation makes a lot of sense.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback