📜  useEffect 与 axios react - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:42.483000             🧑  作者: Mango

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