📜  在反应中等待获取 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:11.798000             🧑  作者: 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);
  }