yappiest-sapphire•2y ago
API get call. Whole response in a variable?
Hey i want to make an api get call and it works but how can i capture the whole api response in a variable?
4 Replies
noble-gold•2y ago
When you make a successful API call in voiceflow, the whole response automatically gets saved in a variable called response. You can access this variable inside the API step itself.
yappiest-sapphireOP•2y ago
ok thank you
rising-crimson•2y ago
I passed the entire response object in a variable and tried to retrieve it in a function block. I am unable to do so... if I pass discrete fields it works fine. would appreciate any guidance
In Functions, you are limited to passing variables that are of string type.
Since the API response comes in the form of an object, you'll need to convert it into a string format. To achieve this, use the
Set
step with the following code: JSON.stringify({your_variable})
.
After converting your variable into a string, you can then pass this stringified version to your Function. Within your Function, to revert the string back into an object, you should use: JSON.parse(your_variable)
.