Użyj efektów z Axios React

let [ posts, setPosts ] = useState([])
  useEffect(() => {
    async function getResults() {
      const results = await axios('https://jsonplaceholder.typicode.com/posts');
      setPosts(results.data)
    }
    getResults()
  },[])
console.log(posts)
Moise Mbakop