0

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.

SMPLYJR
  • 854
  • 1
  • 11
  • 23
  • Are you saying that your Lambda is responding with a request for the date before completing the call to openWeatherMap api? Or are you saying your Lambda is receiving two slots from the client {city} {date}, and you want to complete check weather based on {city} before weather check based on {city} and {date}? Either way, it'll probably be best if you post the relevant code in your question. – K Mo Aug 01 '19 at 10:22
  • HI @KMo, sorry for the confusion. The first one you mention is what actually happening. When the clients send the city, my axios from lambda sends a get request to weather api, but before the request ends and before i get the response, the next slot which is the date is immediately fire. – SMPLYJR Aug 01 '19 at 23:22

0 Answers0