Try Catch on External API Call
I am using Try/Catch on an external API call (actually an internal call) with the Catch block calling another external API call (internal call) if the first one fails. I've tried erroring out with a precondition, as well as throwing an error with a return value. In the former case, I just see the error from the Try block an the Catch never executes - ditto with throwing an error. If I return that value within the Try block, it always executes the Catch block.
Is there any way to get Try Catch to work with external API call functions?
For reference, I am using internal calls because I have an "optional authentication" user facing endpoint where different data is returned (or none at all) depending upon authentication and parameters provided (4 different permission sources with 2 tiers of access).
Comments
-
Hey, @cw. Try/Catch will never react as expected with an external API call because that function will never return an error that would halt your function stack execution. If you need different behaviors based on the result of an external API call, using a Conditional If/Then statement would be the way to go.
-
That works - thank you!
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