Endless API requests in react and nodejs application

Viewed 30

No matter the component I am in, I keep getting infinite requests. I saw these infinite requests in the chrome developer tool network section. This is how the request address looks like:

ws://localhost:3000/ws

The request name is ws. The status code is: 101 Switching Protocol. The application is a MERN stack application. I am using axios to handle the requets. Here is an example of one of my API calls with axios:

//fetch user
useEffect(()=>{
  const ourRequest = axios.CancelToken.source() 

  const fetchSingleUser = async () =>{
    const response = await axios.get(`/users/singleUser/${path}`,{cancelToken: ourRequest.token})
    setUser(response.data);
  }

  fetchSingleUser()
  return () => {
    ourRequest.cancel()
  }
}, [])

What could be causing these requests?

0 Answers
Related