async and await

Posted ronle

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了async and await相关的知识,希望对你有一定的参考价值。

  async function getIPAddress () 
    const url = ‘https://httpbin.org/ip‘
    const req = await fetch(url)
    const json = await req.json()
    const data = await json.origin
    console.log(data)
  
  getIPAddress()

 

以上是关于async and await的主要内容,如果未能解决你的问题,请参考以下文章

async和await

async 和 await

async和await

async和await

Async Function 背后的秘密

promise和async的区别