score:1

Accepted answer
  useEffect(()=>{
     axios.get('http://localhost:4000/todos').then((res)=>{
          {console.log(res.data)}
          setState({
            ...state,
            data: {...state.data, res.data}
          })
          {console.log(state)}
     })
  }, []) // Empty array brackets means you want only one time your component to do the things mentioned in `useEffect`, Brief [guide][2].

score:0

  useEffect(()=>{
     axios.get('http://localhost:4000/todos').then((res)=>{
          {console.log(res.data)}
          setState({
            ...state,
            data: res.data,
          });
          {console.log(state)}
     })
  })

Related Query

More Query from same tag