Answers for "useEffect with axios react"

2

useEffect with 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)
Posted by: Guest on March-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language