Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Control your API calls by using an amazing component which supports axios and vue-resource

License

NotificationsYou must be signed in to change notification settings

ftgibran/vue-api-request

Repository files navigation

Vue API Request

Vue API Request

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.

Installation

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.

See example in JSFiddle

Basic Usage

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)

Example

<api-request:resource="apiRequest"v-model="apiResponse">  My stuffs to be shown when the API loads</api-request>

Pre Configuration

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.

Example

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.

Contributing

# 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.

License

MITCopyright (c) 2017 Felipe Gibran

About

Control your API calls by using an amazing component which supports axios and vue-resource

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp