I've done my research in regards with making a synchronous
calls and it is not recommended as it is blocking the thread. But in my case, it's different.
I am making a simple weather checker amazon lex
bot. And I have two slots, {city}
and {date}
. When the client ask the bot "Check the weather"
, the bot will then ask the client which city they wanted to check. When the user sends back the {city}
, there is where my axios
from lambda
sends a get request to openWeatherMap
api.
The problem is, after the clients gave the {city}
where he/she wanna check the weather in, the next slot which is the {date}
immediately fire without waiting for the axios call to get finished.
And why am I wanted to wait? Because the axios
call may return an error and I want to capture it and display immediately to the client so that the process will be ended.
Important: Do not get confuse with {date}
slot, I don't really wanted to get the date. I just make it as example, but the concern is to wait for the axios response from the first slot before the following slot will get triggered.