I created a chatbot and want to initiate two Dialogflow API calls within a useEffect Hook. Function 1 and function 2 are both async api calls. The wanted result is that it first finishes function 1 and then starts with function 2, but currently function 2 returns the value faster than function 1.
Do you have any idea how I can tell function 2 to wait until function 1 returns a value?
useEffect(
    () => {
      createChatSessionId();
      fetchEventAnswerFromDialogflow("Startevent" + chatId, chatId); // function 1
      fetchEventAnswerFromDialogflow("Frageevent1", chatId); // function 2
    }, // eslint-disable-next-line
    []
  );
 
    