useeffect axios issues code example
Example: 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)