📜  异步等待类组件反应 - Javascript 代码示例

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

代码示例3
async componentDidMount() {
    // when react first renders then it called componentDidMount()
    const response = await fetch('https://jsonplaceholder.typicode.com/users');
    const json = await response.json();
    console.log(json);
  }