Inputs for the custom function and for the endpoint
![Fredk](https://us.v-cdn.net/6037124/uploads/userpics/YXEICG61ECYZ/nGH3D2K4EH56L.jpg)
I successfully tested my custom function sendgrid_dynamic_send
after barely a week on Xano.
Yet I feel something isn't right. I have about a dozen inputs for my function (all tested with the Run&Debug). Now at the endpoint level, I end up creating a few of those inputs again.
I've digged into this doc but that didn't aleviate my doubts:https://docs.xano.com/api/the-basics/custom#how-to-create-an-api-endpoint
Where can I read more (any relevant link in the forum)?
For example, am I correct in setting all the inputs needed for the personalizations
array of objects inside the function only, and only a personalizations
input at the endpoint level?
Answers
-
In terms of what inputs you need at the API level vs the function level, it really just depends on where the data originates.
As an example, if I have a custom function that is used to update a user's email address in the database, and the value to use is coming from a user's input on the front-end, I would need that input at the API level so my front-end can pass it along.
If my custom function needs that data, but maybe I'm pulling it from a database query, or an external API request, that would mean that my endpoint does not need those inputs because they are populated in my function stack.
So, the tl;dr is that if the data comes from user input, you'll likely need this in your API's inputs. If it comes from a step in the function stack, you probably don't need an input defined in the API for this.
-
Chris, thanks.
I've set all my inputs (data from front end) in the endpoint now, for example ‘subject’.
But now I also need this input again at the function level too, don't I? (as it is required in the request body of api.sendgrid.com/v3/mail/send)
-
Yep, any of those input you need for that function to run, you will want to set up in your function.
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