Blogger Information
Blog 35
fans 0
comment 0
visits 16740
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
fetch / async / await
手机用户311660634
Original
458 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>fetch / async / await </title>
  8. </head>
  9. <body>
  10. <script>
  11. // fetch
  12. fetch('https://jsonplaceholder.typicode.com/todos/9')
  13. .then((Response) => Response.json())
  14. .then((json => console.log(json)))
  15. // async await function 前面假async,使它变成一个异步函数
  16. async function getUser(){
  17. let url = 'https://jsonplaceholder.typicode.com/todos/8'
  18. const response = await fetch(url)
  19. const result = await response.json()
  20. console.log(result)
  21. }
  22. </script>
  23. </body>
  24. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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