How external API requests work in a functional stack
If I add an external API request in the middle of a stack at Step X, will my functional stack wait for a response from this API request before going further or it will just hit and move forward? I have an API (used to send a Whatsapp message) that sometimes takes time. Its response is irrelevant to the rest of the stack. I don't want my functional stack to get delayed because of this sluggish API.
Best Answers
-
Hi @vk - yes your Function Stack will wait for the external API request to finish before continuing on through the stack. However, if the response is irrelevant to the rest of the stack, you could try to set the timeout setting of the external API request call to very low. The function will timeout and continue down the rest of the function stack but the external call should be "Triggered".
-
Sure. In the below example, I'm first defining a message payload, and then using axios to make a POST request to my API.
const payload = { phone: "recipient", text: "message"};
axios.post('https://myapi.com/webhook', payload);Of course, the exact structure of the request will be dependent on the API you are using. It's hard for me to give exact instruction based on the Whatsapp API as I'm not directly familiar, but using Axios to make the call is pretty straight forward. As a non-dev like myself, I honestly lean on ChatGPT a lot to write my code if the API documentation doesn't provide sample code for me.
Answers
-
You can also use a Lambda function to call the API async if the response doesn't matter.
-
Hi Chris! Any chance you can share a sample? Imagine I am sending a one-sided message payload to Whatsapp APIs to deliver a message.
-
I believe post-processing capability streamlines this a lot. I can put non-mandatory APIs in post-processing. Even if there is an error, nothing hurts the core part of API. I hope my understanding is correct - @Chris Coleman / @Michael Udinski?
-
Yes @vk Post Process now streamlines this scenario :)
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