//异步请求 fetch().then().then()// function getData(){// fetch('https://jsonplaceholder.typicode.com/todos/')// .then(response => response.json())// .then(json => console.log(json))// }// 异步函数 async awaitasync function getData(){//请求urllet url = 'https://jsonplaceholder.typicode.com/todos/'// 等待请求的结果,在进行后面的操作const response = await fetch(url);//响应成功以后,将进行转为json处理const res = await response.json();console.log(res)}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号