How to return a value only if it is set?
Options
Ambroise
Member ✭
The value `ongoingTimeCategorizationUpdated` is only present when a couple of conditions are true. This leads to an issue when it's not set.
Is there a way to handle that use case gracefully? I'd like to avoid an extra action, if possible.
Answers
-
Add the extra function step - create variable ongoingTimeCategorizationUpdated and set it to null. This is practically free from a computation point of view. The subsequent create variable call will just update it in place.
-
Okay, that's what I had in mind but I wanted to know if there weren't a simpler way to do this, because it's fine for a single variable, but if the endpoint grows, it can lead to a lot of noise - I was hoping to tell the Return step to only return it if present, something like that.
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