Blogger Information
Blog 37
fans 0
comment 1
visits 28492
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
异步函数请求
kong
Original
143 people have browsed it
  1. //异步请求 fetch().then().then()
  2. // function getData(){
  3. // fetch('https://jsonplaceholder.typicode.com/todos/')
  4. // .then(response => response.json())
  5. // .then(json => console.log(json))
  6. // }
  7. // 异步函数 async await
  8. async function getData(){
  9. //请求url
  10. let url = 'https://jsonplaceholder.typicode.com/todos/'
  11. // 等待请求的结果,在进行后面的操作
  12. const response = await fetch(url);
  13. //响应成功以后,将进行转为json处理
  14. const res = await response.json();
  15. console.log(res)
  16. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post