vue-httpclient-axios
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

vue-httpclient-axios

The Wrapper for integrating Axios into vue

Usage

Install

    npm i vue-httpclient-axios

Register plugin

  • Options explain
    • null do not set option
Vue.use(
    HttpClient,
    Vuex, // Vuex object
    interceptors, // interceptors
    axiosConfig // Axios config option
 )
import {
    HttpClient,
    Axios // Axios object
} from 'vue-httpclient-axios'

Vue.use(HttpClient) // The ignorepermissionverify method is used by default

// custom
Vue.use(HttpClient, store, data => {
    if (data.status == 401) {
        // Unauthenticated
        //  return
    }

    else if (data.code == 403) {
        // NoPermissions
        //  return
    }

    return data
})

// In Vue
this.$http
// ...

// In Vuex
this.http
// ...

Method

  • HttpClient

    • sessionKey: 'TOKEN',
    • tokenHeader: 'Bearer',
    • requestHeaderName: 'Authorization',
    • ignorePermissionVerify(data);
  • this.$http and this.http

    • getAuthorization()
    • setAuthorization(value: string)
    • setAuthorizationHeader(value: string)
    • setContentType(value: string)
    • setPostContentType(value: string)
    • setValidateStatus(value: ((status: number) => boolean) | null)
    • setResponseType(value: string)
    • setWithCredentials(value: boolean)
    • setBaseURL(value: string)
    • setTimeout(value: number)

Package Sidebar

Install

npm i vue-httpclient-axios

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

8.4 kB

Total Files

4

Last publish

Collaborators

  • fuile