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()

 

posted @ 2019-07-20 15:29  ronle  阅读(93)  评论(0编辑  收藏  举报