'How to use setInterval for real time notofication with reactJs?

I want to use setInterval to make real time notification with reactjs But I don't Know how to integrate it in my laravel api call . this is my code :

  useEffect(() => {
    getData();
  }, [])
  async function getData() {
    let result = await fetch(`${API_ENDPOINT}/api/listComplain`);
    result = await result.json();
    setData(result)
  }

Any Suggestion please



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source