I am calling a authentication token using an api call but it keeps returning new tokens

I am sending an api call to cognito to get a jwtToken in return. I am using hooks for the API call but the issue is that I am getting infinite number tokens in return as the API call keeps getting data.

useEffect(() => {
    Axios.post(`${apiUrl}/api/auth/login`, loginInfo).then((res) =>
      setToken(res.data.accessToken.jwtToken)
    );
    Axios.get(getEventsUrl, config).then((response) =>
      setEventsData(response.data)
    );
  }, [loginInfo]);

How do I end only one request?