Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 626 Bytes

README.md

File metadata and controls

42 lines (30 loc) · 626 Bytes

@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