📜  在函数组件中等待响应 - Javascript 代码示例

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

代码示例2
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);
  }