- Notifications
You must be signed in to change notification settings - Fork9
Control your API calls by using an amazing component which supports axios and vue-resource
License
ftgibran/vue-api-request
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Vue API Request provides a full control on your APIs, making the calls simple, fast and easy to implement. Also, your code will be cleaner and more elegant.
Package is installable via NPM
$ npm i vue-api-request --save
or via Yarn
$ yarn add vue-api-request
or via CDN
<scriptsrc="https://unpkg.com/vue-api-request@latest/dist/vue-api-request.min.js"></script><linkhref="https://unpkg.com/vue-api-request@latest/dist/vue-api-request.min.css"rel="stylesheet"/>
It will setwindow.VueApiRequest as the module.
You have to import the library and use as a Vue plugin to enable the functionality globally on all components.
importVuefrom'vue'importVueApiRequestfrom'vue-api-request'Vue.use(VueApiRequest)
<api-request:resource="apiRequest"v-model="apiResponse"> My stuffs to be shown when the API loads</api-request>
You may also set your own default configuration, so you don't need to customize every time each ApiRequest component. You are still able to customize a specific component using props.
importVuefrom'vue'importVueApiRequestfrom'vue-api-request'letoptions={effect:'lightSpeedIn',resp:'body.foo.bar',spinner:'DotLoader',spinnerColor:'blue',//or #0000ffspinnerPadding:'2em',spinnerScale:1.4,onSuccess:resp=>{console.log('Success',resp)},onError:resp=>{alert(`Error:${resp.message}`)}}Vue.use(VueApiRequest,options)
The 'options' variable above is equivalent of:
<api-request:resource="apiRequest"v-model="apiResponse"effect="lightSpeedIn"resp="body.foo.bar"spinner="DotLoader"spinner-color="blue"spinner-padding="2em":spinner-scale="1.4"@success="successEvent"@error="errorEvent"> My stuffs to be shown when the API loads</api-request>
Go toDemo & Docs to further informations.
# clone projectgit clone https://github.com/ftgibran/vue-api-request.gitcd vue-api-request# install dependenciesnpm install# serve with hot reload at localhost:8080npm run dev# build for production with minificationnpm run build# build for production and view the bundle analyzer reportnpm run build --report# run unit testsnpm run unit# run e2e testsnpm run e2e# run all testsnpmtest
For detailed explanation on how things work, checkout theguide anddocs for vue-loader.
MITCopyright (c) 2017 Felipe Gibran
About
Control your API calls by using an amazing component which supports axios and vue-resource
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
