npm.io
0.2.11 • Published 4 years ago

@vueblocks/vue-use-axios

Licence
MIT
Version
0.2.11
Deps
5
Size
11 kB
Vulns
23
Weekly
0
Stars
35

@vueblocks/vue-use-axios

Use Axios With Composition API Easily.

Install

yarn add @vueblocks/vue-use-axios

Usage

useAxios is a wrapper of Axios

import { useAxios } from '@vueblocks/vue-use-axios'

export default {
  ...
  setup () {
    const url = 'https://api.coindesk.com/v1/bpi/currentprice.json'

    const { refetch, data } = useAxios(url)

    const fetchBitcoinPrice = () => {
      setInterval(() => {
        refetch()
      }, 20000)
    }

    return {
      data,
      fetchBitcoinPrice
    }
  }
  ...
}

License

MIT @xiaoluoboding

Keywords