1.0.6 • Published 2 years ago

vue-ldc-axios v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Installing

Using npm:

$ npm i vue-ldc-axios

Example

import { apiGet } from 'vue-ldc-axios/api';

apiGet('domain', {
    params: params
}).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

Environment Variables

NameTypeDefault valueDescription
VUE_APP_API_URLString/Base domain api.
VUE_APP_KEY_ACCESS_TOKENStringaccess_tokenKey get token in cookie.
VUE_APP_KEY_REFRESH_TOKENStringNullKey get refresh token in cookie.
VUE_APP_TOKEN_BEARERStringNullBearer before token.
VUE_APP_KEY_SET_AUTHStringAuthorizationKey set header authentication.

Note Environment Variables

VUE_APP_KEY_REFRESH_TOKEN but null there will be no mechanism refresh token

when VUE_APP_KEY_REFRESH_TOKEN yes then we will get function callRefreshToken from '@/config/vue-ldc-axios' handle the refresh token

Note that the callRefreshToken function must be a Promise, if not a Promise, we are not responsible for the results returned to you.

If the token refresh is successful, the Promise return the token, not the refresh token

callRefreshToken you will save your own token and refresh token

Methods:

import 'vue-ldc-axios';
import { apiGet, apiPost, apiPut, apiDelete } from 'vue-ldc-axios/api';

# api get
apiGet('domain', {
    params: params
}).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

# api post
apiGet('domain', {
    form: form
}, {
    // headers
}).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

# api put
apiPut('domain', {
    form: form
}, {
    // headers
}).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

# api delete
apiDelete('domain', {
    params: params
}).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

Note method

All catch we run through a function actionCatchApi from '@/config/vue-ldc-axios' for you to handle in general

Git

nglinhbk

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago